I still had a few questions to @Mark because you did get a correct output in certain cases. He gave me the following answer:

When the output is text, the conversion is done inside Javascript, where the floating point number stays in the 64 bit space. That produces a correct string result. 

The JS actor outputs as integer by default, connect it to a text actor to mutate the output to text. 

Best Michel