Giter VIP home page Giter VIP logo

math's Introduction

Math

A Solidity math library with overflow checking

Version: 0.5.0

example usage:

pragma solidity ^0.4.11;

import "Math.sol"

contract K{
    using MathU for uint;
    uint num;
   
    function foo(uint x) {
        ...
        num = num.add(x);
        ...
    }
}

add

a add to b

function add(uint a, uint b) internal pure returns (uint c)

sub

a subtract b

function sub(uint a, uint b) internal pure returns (uint c)

mul

a multiplied by b

function mul(uint a, uint b) internal pure returns (uint c)

div

a divided by b

function div(uint a, uint b) internal pure returns (uint c)

inc

Increment a

function inc(uint a) internal pure returns (uint c)

dec

Decrement a

function dec(uint a) internal pure returns (uint c)

pow

Raise a to power of b (Warning: no overflow checking)

function pow(uint a, uint8 b) internal pure returns (uint c)

eq

Equates a to b

function eq(uint a, uint b) internal pure returns (bool)

lt

a less than b

function lt(uint a, uint b) internal pure returns (bool)

gt

a greater than b

function gt(uint a, uint b) internal pure returns (bool)

lteq

a less than or equal to b

function lteq(uint a, uint b) internal pure returns (bool)

gteq

a greater than or equal to b

function gteq(uint a, uint b) internal pure returns (bool)

isZero

a is zero

function isZero(uint a) internal pure returns (bool)

cmp

Parametric comparitor test. a > b where sym == true a < b where sym == false

function cmp(uint a, uint b, bool sym) internal pure returns (bool)

cmpEq

Parametric comparitor test. a >= b where sym == true a <= b where sym == false

function cmpEq(uint a, uint b, bool sym) internal pure returns (bool)

cmpTri

Trinary comparitor returning int -1, 0, 1 for LT, EQ, GT

function cmpTri(uint a, uint b) internal pure returns (int8)

tox

Safe uint casting for uint lengths 8,16,32,40,48,56,64,72,80,96,128,192

function uint64(uint a) internal pure returns (uint64 b)

math's People

Contributors

o0ragman0o avatar

Stargazers

pospi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.