library MathFunction 
{
    // standard uint256 functions

    function plus(uint256 x, uint256 y) constant internal returns (uint256 z) {
        assert((z = x + y) >= x);
    }

    function minus(uint256 x, uint256 y) constant internal returns (uint256 z) {
        assert((z = x - y) <= x);
    }

    function multiply(uint256 x, uint256 y) constant internal returns (uint256 z) {
        z = x * y;
        assert(x == 0 || z / x == y);
    }

    function divide(uint256 x, uint256 y) constant internal returns (uint256 z) {
        z = x / y;
    }
    
    // uint256 function

    function hplus(uint256 x, uint256 y) constant internal returns (uint256 z) {
        assert((z = x + y) >= x);
    }

    function hminus(uint256 x, uint256 y) constant internal returns (uint256 z) {
        assert((z = x - y) <= x);
    }

    function hmultiply(uint256 x, uint256 y) constant internal returns (uint256 z) {
        z = x * y;
        assert(x == 0 || z / x == y);
    }

    function hdivide(uint256 x, uint256 y) constant internal returns (uint256 z) {
        z = x / y;
    }

    // BIG math

    uint256 constant BIG = 10 ** 18;

    function wplus(uint256 x, uint256 y) constant internal returns (uint256) {
        return hplus(x, y);
    }

    function wminus(uint256 x, uint256 y) constant internal returns (uint256) {
        return hminus(x, y);
    }

    function wmultiply(uint256 x, uint256 y) constant internal returns (uint256 z) {
        z = cast((uint256(x) * y + BIG / 2) / BIG);
    }

    function wdivide(uint256 x, uint256 y) constant internal returns (uint256 z) {
        z = cast((uint256(x) * BIG + y / 2) / y);
    }

    function cast(uint256 x) constant internal returns (uint256 z) {
        assert((z = uint256(x)) == x);
    }
}
function plus(uint256 x, uint256 y) constant internal returns (uint256 z) {
    assert((z = x + y) >= x);
}

// standard uint256 functions