indutny / bn.js

BigNum in pure javascript
MIT License
1.19k stars 150 forks source link

muln with fractional number gives wrong result #276

Closed mahnunchik closed 3 years ago

mahnunchik commented 3 years ago

muln method gives wrong result using fractional number for numbers up to 67108864.

new BN('67108864', 10).muln(0.5)
// actial 0
// expected 33554432

Numbers less than 67108864 works as expected:

new BN('67108863', 10).divn(2)
// 33554431
mahnunchik commented 3 years ago

@indutny @fanatid please have a look at this issue

Yaffle commented 3 years ago

@mahnunchik , I don't think fractional numbers are supported by this library, try new BN(0.5).toString()

fanatid commented 3 years ago

Fractional numbers are not supported.