Skip to content

Integer library with unlimited precision for EOS.IO Smart Contract

Notifications You must be signed in to change notification settings

swapnibble/biginteger-for-eosio

Repository files navigation

BigInteger for EOS.IO

BigInteger library for EOS Smart Contract

Table of contents

You can use this library in a EOS Smart contract to do arithmetic without any precision limit.

This library has been tested on EOS.IO DAWN 2.x . See EOSIO github.

Original author

Matt McCutchen ( C++ Big Integer Library )

Example


 #include "eoslib/print.hpp"  
 #include "BigIntegerLibrary.hpp"  
    
 BigInteger a = 65536;  
 print("a * a * a * a * a * a * a * a: ", ( a * a * a * a * a * a * a * a ) );  

then, eosd prints 340282366920938463463374607431768211456.

Operators


arithmetic : +, -, *, /, %, ++(pre, post), --(pre, post), +=, -=, *=, /=, %=, etc.. ( see header for more details )
bit : &, |, ^, <<=, >>= , etc.. ( see header for more details ) 

Build

eoscpp -o <wastOutput.wast> <yourContractSrc.cpp> eos_mem_wrapper.cpp BigInteger.cpp BigIntegerAlgorithms.cpp BigIntegerUtils.cpp BigUnsigned.cpp BigUnsignedInABase.cpp

If linker complains about memory_heap variable, then change as followings:

find memory_heap variable in memory.hpp ( eoslib )
then, change :


static memory_manager memory_heap;

About

Integer library with unlimited precision for EOS.IO Smart Contract

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages