There is always an error in the calculation of the amount by node. Is there a security arithmetic module that is often used?

for example,
0.1 "0.2" 0.3 "0.4" 0.5 "0.7" 0.8 "0.9" 1.0 "1.1" 1.2 "1.3" 1.4 "1.5" 1.6 "1.7
the result is
15.299999999999999

read an article that can be written with add module, but in practice, not only addition, subtraction, multiplication and division will have errors, but there seems to be errors in addition, subtraction, multiplication and division. It seems that there are modules such as safe math in the image, so what kind of security calculation module do you usually use?

Mar.10,2021

if there is a maximum length limit for decimal places, and there is no need to calculate large numbers, you can convert it into an integer first and then convert it back to
or write your own algorithm. Something like this

bignumber


floating point operation may have errors.
therefore, it is common to convert the floating point to an integer and then back to the floating point after the operation.
you can use Baidu's "floating point operation error".

Menu