dragome-sdk icon indicating copy to clipboard operation
dragome-sdk copied to clipboard

Double#longBitsToDouble wrong result

Open xpenatan opened this issue 8 years ago • 2 comments

Using this code:

double d = 1.5187d;
long bits = Double.doubleToLongBits(d);

Desktop: bits = 4609518435926734484 Dragome: bits = 2146891412

xpenatan avatar Jan 16 '17 00:01 xpenatan

I guess this wont be possible to get it right because of javascript limitation.

xpenatan avatar Jan 16 '17 12:01 xpenatan

JavaScript only supports 53 bit integers

http://www.2ality.com/2012/07/large-integers.html

In JavaScript, all numbers are 64 bits floating point numbers. This means you can't represent in JavaScript all the Java longs. The size of the mantissa is about 53 bits.

https://stackoverflow.com/questions/17320706/javascript-long-integer

nicolaichuk avatar Feb 28 '17 18:02 nicolaichuk