ttulka / as-big

AssemblyScript library for arbitrary-precision decimal arithmetic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

different value in toString on big decimal numbers

m7vicente opened this issue · comments

I am implementing some math algorithms in assembly script to use as module in node JS.

In some cases, when I try to parse Big to number() o just use the method toF64, it return the fallowing message.
image
and when I try to make an conversion to String the method return an completely different number, like 39264 , what I had no idea the reason.

I also try do debug line to line in visual studio code do catch the error, but I had no success to configure the debugger for it, can you exemplify how to?

Hey @m7vicente, sorry for the late reply.

I guess the problem is that in cases when your Big instance is out of the JS float range you cannot simply convert that Big instance into a float number. If you do so, the floating-point will overflow and you get a wrong "completely different" number. It means converting Big to a number is not a "safe" operation.

If you think this explanation doesn't apply, show me the problematic code, please.