Multiplication of same number in Java and Javascript giving different values

Ankit Arora :

I have an expression which I am evaluating both in Java and JavaScript.

Java

System.out.println(582344008L * 719476260);

Output: 418982688909250080

Javascript

document.write(582344008 * 719476260)

Output: 418982688909250050

Why is there a difference in both values?

baseballlover723 :

Javascript numbers are all IEEE 754 doubles, so it looks like there is some floating point error going on here. see Difference between floats and ints in Javascript? for some more details

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=144300&siteId=1