0
votes

I have some math on frontend, which works good, but when math calculate big Numbers like this 1.1350120633522164e+23

I get error

Unhandled Rejection (Error): invalid number value (arg="minDestinationAmount", coderType="uint256", value="1.1350120633522164e+23", version=4.0.44)

I used BN

   const minDestBN = new BigNumber(input) 

   const  minDestinationAmount = minDestBN.multipliedBy(99).dividedBy(100)

res minDestinationAmoun = 1.1350120633522164e+23

How to convert such numbers 1.1350120633522164e+23 to uint256 on frontend side ?

1

1 Answers

0
votes

This help me

    BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
    let minDestinationAmount = minDestBN.multipliedBy(99).dividedBy(100)
    minDestinationAmount = String(minDestinationAmount)

But would be great to hear best practice