iost.js icon indicating copy to clipboard operation
iost.js copied to clipboard

Use `Math.trunc` instead of `parseInt`.

Open monaka opened this issue 5 years ago • 1 comments

In some cases, parseInt() will return unexpected values.

parseInt(0.000001)
0
parseInt(0.00000001)
1

Math.trunc() is safer.

monaka avatar Nov 13 '19 07:11 monaka

Note: As you might know, Math.trunc() isn't supported by some ancient Web browsers. IMO, they are no value to support. But if you don't suppose so, it will be required to add some configuration to Babel (polyfill).

monaka avatar Nov 13 '19 07:11 monaka