incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe David Manana <fdman...@gmail.com>
Subject Re: Integers changed to float in Couch 0.11.0
Date Fri, 09 Apr 2010 17:13:02 GMT
On Fri, Apr 2, 2010 at 3:37 PM, Paul Davis <paul.joseph.davis@gmail.com>wrote:

>
> Well, there's a limit to what can be stored in an integer remember. I
> wouldn't really hold my breath for anything larger than 2147483648
> (2^31). The reason that Futon shows something different is because
> JavaScript treats all numbers as floats and then at display time it'll
> not display a fractional part if it's zero.
>
> I'm suprised that it used to work. Can anyone else on 0.10 verify
> that? I'm not sure if I remember anything changing in the number
> handling in mochijson or not.
>
>
It changed:

http://code.google.com/p/mochiweb/source/detail?r=43

JSON (and JavaScript) doesn't have a float or integer type. Everything is of
type number. So anything greater than (2^31) - 1 can be represented without
the decimal separator.

In JavaScript:

>>> n1 = 1270162450695
1270162450695
>>> n2 = 1270162450695.0
1270162450695
>>> n1 === n2
true

I dunno why mochijson2 is making a distinction between integers vs floats.



> HTH,
> Paul Davis
>



-- 
Filipe David Manana,
fdmanana@gmail.com

"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message