I am working on a finance application where a small decimal point matters a lot. While I was working at it, I discovered that js changes the actual value when transforming to to hex and decimal to and fro.
For example:
a = (parseFloat(49098.40463663199) * 10 **18).toString(16)
gives me
a65a13dc28529800000
Adding 0x at the beginning and dividing by the number it was multiplied to changes the number slightly like:
0xa65a13dc28529800000 / 10 ** 18
gives me
49098.40463663198
Notice that the value decreased by 0.00000000001
?
I want to avoid this. How can I?