Skip to content

Decimals being removed #49

@ShaunLWM

Description

@ShaunLWM

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions