big.js
Brick\Math
big.js | Brick\Math | |
---|---|---|
9 | 10 | |
4,679 | 1,747 | |
- | 1.4% | |
0.0 | 7.4 | |
about 1 year ago | 9 days ago | |
JavaScript | PHP | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
big.js
-
Decoding Why 0.6 + 0.3 = 0.8999999999999999 in JS and How to Solve?
ii) Third-Party Libraries There are various libraries like math.js, decimal.js, big.js that solve the problem. Each library functions according to its documentation. This approach is comparatively better.
-
Working with Currency Values in TypeScript
For financial applications, APIs commonly return currency values, balances, stock/currency positions, and other amounts as strings. The best way I've found to deal with this is to use a library like big.js.
-
Working with extremely large numbers?
Just for fun, using javascript library:
-
How are you handling your money?
Another different approach maybe to have the money represented in the decimal in your database at the decimal places of the currency with the highest decimal point you are going to be dealing with for example using Decimal(n, 2) in case of fiat, and perform your calculations in arbitrary-precision Decimal type. In javascript, using libraries like Big.js , Decimal.js will be of help.
-
Made my first JavaScript project, the calculator!
With that said, using a library like big.js will solve both this and the potentially unsafe eval use:
- Ask HN: Open-source projects that handle monetary values properly
- Is there a way to monitor the price on pancake swap through an API?
-
Why is 7.9 - 5 = 2.90000004?
It will explain this weird behavior. You have to use a special lib for precise floating point math. Here is one: big.js.
Brick\Math
-
PHP libraries and tools
brick/math: Arbitrary-precision arithmetic library for PHP
-
PHP is trolling me
Use strings. For PHP specifically, the Brick/Math library.
-
[ELI5] Why is it bad to compare floats directly for equality?
There are excellent wrappers for this like https://github.com/brick/math
-
Need Guidance for my Passionate Ecommerce Project
https://github.com/brick/math to handle bignumber and operations
-
How are you handling your money?
In Java and Ruby, BigDecimal is an inbuilt class that can be used. For PHP, you can checkout the Brick Math Library Basically, just find the arbitrary-precision Decimal type/Class/Library in your choice of language. Got another approach, please do let me know in comment section.
- Weekly "ask anything" thread
-
What are the latest thoughts on storing and working with very large and very small financial transactions?
I decided to use https://github.com/brick/math and store the amount as a string in the database. My project use NANO, so that's 30 decimal points to keep. Number type column is not the choice at all.
-
Vote for enums in PHP 8.1 has started — looking good so far!
There are many use cases where enums don't need to be backed by a scalar. I'm thinking of brick/math's RoundingMode for example: you use these in code, but never store/serialize them really.
-
(int) (round(19.33, 2) * 100) = 1932 - can someone please explain this to me?
Besides, using an arbitrary-precision library gives you an unlimited number of digits, and, in the case of brick/math, many more rounding modes to choose from. And predictable ones.
What are some alternatives?
human-standard-token-abi - A JSON ABI for the Ethereum ERC 20 Token Standard
decimal-object - Decimal handling as value object instead of plain strings.
v2-core - 🦄 🦄 Core smart contracts of Uniswap V2
BigNum-PHP - BigNum library for PHP compatible with bn.js
PHP Parser - A PHP parser written in PHP
Brick\Money - A money and currency library for PHP
ip - Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Money - PHP implementation of Fowler's Money pattern.
Fermat - A library providing math and statistics operations for numbers of arbitrary size.
PHP Units of Measure - A library for handling physical quantities and the units of measure in which they're represented.
break_infinity.js - A replacement for decimal.js for incremental games who want to deal with very large numbers (bigger in magnitude than 1e308, up to as much as 1e(9e15) ) and want to prioritize speed over accuracy.
php-units-of-measure - A library for handling physical quantities and the units of measure in which they're represented.