1

I need to sort very small values. These values are come from javascript to java.

There is difference between java value and javascript value

"9.466330862652141E-30" in javascript

is

"9.466330862652142E-30" in java

"javascript double" use IEEE 754 (11 exponent bits) "java double" also use IEEE 754 (11 exponent bits)

I know about 100% precision of 15 decimal point. But I don't need accuracy.. I just need completely same value between javascript and java.

What is the cause of my case?

llllllllll
  • 16,169
  • 4
  • 31
  • 54
  • 1
    I think we'll need to see the code that generates these values, on both systems. – markspace May 06 '18 at 17:17
  • 1
    Not only what @markspace said, but also Java may calculate doubles differently than Javascript given that they are two completely unrelated languages – Kwright02 May 06 '18 at 17:20
  • If you don't need accuracy, then reduce the precision such that you get the same representation on both platforms. The cause of the difference seems immaterial. –  May 06 '18 at 17:23
  • I'd try to convert double to its bit representation and send as long, then convert back, check `longBitsToDouble` in java and [this answer](https://stackoverflow.com/a/14379836/2864275) for javascript – Iłya Bursov May 06 '18 at 17:45

0 Answers0