views:

107

answers:

2

Can anyone tell me how to compare large numbers in javascript?

Something like

var sla = 1263293940000;
var resp = 1263296389700;

if(sla > resp)
{
    //do something
}
+1  A: 

You might want to look into the BigInteger library.

Alex Reisner
+1  A: 

Internally all javascript numbers are represented as double-precision floating point numbers. As you've discovered, this causes some rounding errors for very large numbers (and in other places). If you need more precision, you'll need to use a library like the one Alex posted.

Gabe Moothart