Giter Site home page Giter Site logo

evm-bn's Issues

BigNumber percentage with calculation with evm-bn

Hello, I'm trying to write some TypeScript versions of functions using PRBMath Solidity Library. One thing I am having trouble with is modeling TypeScript functions the same way as the Solidity ones.

For example, in Solidity you can do something like .25e18 to model 25% out as a Big Number, and multiple X by .25e18 to get 25% of X.

uint256 twentyFivePercent = X.mul(.25e18);

With TypeScript, I have not been able to find an equivalent, even with these wonderful libraries like evm-bn. I believe I'm just doing something wrong here, and would love an example for how I can achieve the above using evm-bn.

Thanks!

Some issues with negative exponential numbers (scientific e notation)

I noticed that when representing very small numbers like 10 * 10-18 (10 with 0 decimals), the following line works: fp("1e-17"), while the following line doesn't fp("10e-18"). Apparently, fp("10e-18") is internally interpreted to be equal to 1 * 10-18, so does fp("100e-19") and fp("1000e-20").

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.