couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Kocoloski <kocol...@apache.org>
Subject Re: Silent corruption of large numbers
Date Wed, 11 Nov 2009 01:03:25 GMT
On Nov 10, 2009, at 8:00 PM, Noah Slater wrote:

>
> On 11 Nov 2009, at 00:52, Adam Kocoloski wrote:
>>
>> Hi Noah, I think the part you're missing is that JavaScript does  
>> not actually have integers.  All numbers are internally represented  
>> using double-precision floating point.  So in fact a number that  
>> looks like an integer can be corrupted.  Easiest way to see this,  
>> as Roger pointed out, is to try to enter something like
>>
>> 9223372036854775807
>>
>> as the value for a field in Futon.  You can't do it, Futon will  
>> corrupt it and give you back
>>
>> 9223372036854776000
>
> Isn't it just the case that there is a ceiling for representable  
> integers, then?

Yes, that's correct.  The awkward part is that if you exceed that  
ceiling JS doesn't complain, it just starts rounding.  A surprising  
result for a developer coming from, well, any other language that I  
know of.

Adam


Mime
View raw message