Interested in the question of whether there are similar libraries in javascript, as in PHP (for example, BCMATH ) for performing arithmetic operations with the necessary accuracy?
Ps From 0.2 subtract 0.01808 and get 0.18192000000000003
Interested in the question of whether there are similar libraries in javascript, as in PHP (for example, BCMATH ) for performing arithmetic operations with the necessary accuracy?
Ps From 0.2 subtract 0.01808 and get 0.18192000000000003
Use the toFixed method, I don’t know about the library, but you can write a function and specify an accuracy parameter.
const result = 0.2 - 0.01808; console.log(+result.toFixed(5)) Source: https://ru.stackoverflow.com/questions/881408/
All Articles
0.20.01808? - Dmytryk