paulrberg / evm-bn Goto Github PK
View Code? Open in Web Editor NEWConvert fixed-point numbers to ethers big numbers and vice-versa.
License: MIT License
Convert fixed-point numbers to ethers big numbers and vice-versa.
License: MIT License
Hi @PaulRBerg, would like to open a PR for this, if you think it's a good idea to migrate as ethers now use bigint in v6.
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!
Make it possible to provide the number of decimals as an optional second argument. The minimum value permitted should be 1, and the maximum 77.
E.g., fp("10,000,000.256")
is a lot easier to read than fp("10000000.256")
.
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")
.
Turn the current default export into a toBn
function, and add a new function fromBn
that converts from a BigNumber
to a string
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.