margelo / react-native-bignumber

🔢 The fastest Big Number library for React Native
https://margelo.io
MIT License
342 stars 12 forks source link

Decimals being removed #49

Open ShaunLWM opened 2 years ago

ShaunLWM commented 2 years ago

Please correct me if I'm wrong. I realised the decimals are being chopped off when creating a new instance of a string and then converting it back to a string (with or without any additional methods used).

const price = "10.50";
console.log(price); // 10.50

const bn = new BN(price);
console.log(bn.toString(10)); // 10

const bn2 = new BN(price, 10);
console.log(bn2.toString(10)); // 10

 console.log(bn.mul(new BN(3)).toString(10)) // 30
dani-z commented 1 year ago

Hm I am gettings the same 🤔