GithubHelp home page GithubHelp logo

dulumao / float256 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from l0k18/float256

1.0 0.0 0.0 10 KB

Golang library built on top of math/big Float for basic high precision financial calculations for a cryptocurrency ledger with 42:214 fixed precision serialisation

License: The Unlicense

Go 100.00%

float256's Introduction

float256

A cryptocurrency ledger token denomination math library

Golang library built on top of math/big Float for high precision financial calculations, intended for use with a cryptocurrency ledger with a maximum integer part of the maximum supply of 4,398,046,511,103, and an unsigned fixed point 42.214 bit 256 bit form for storage and transmission.

This is mainly just convenience wrappers to make working with big.Float easier (functions simply take variables and return results instead of the confusing return-and-modify in math/big, with an added power function (Exp) and nth root function (Root) that automatically configures for 256 bits of precision.

It also has convenience converters to and from big.Int, string, int64 and uint64, and numerous other standard basic math library functions. There is no trigonometric functions as these are (pretty much) never used in financial calculations, and also largely absent from the base math/big library.

The reason for the high precision of decimals in this library is because it has been written for an upcoming Gocoin fork that has a flat annual supply rate of 3.125% meaning that block rewards relatively rapidly decay at a rate of an average 2 decimal places per year, and an implicit supply limitation via the limit function created by an exponential decay (though if precision is increased when needed there need not be an end to miner block rewards - for which reason there is no transaction fee.)

To make your code a little less wordy you may want to alias the import with a shorter name with or two letters like f, F, or fl or something similar. The return values are plain vanilla *big.Float variables so it is possible to use them in the normal math/big manner should there be any need to inspect internals such as precision, mantissa, exponent, accuracy, and so forth.

float256's People

Contributors

l0k18 avatar

Stargazers

 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.