Also just wanted to point out that though Thrift respects both the float and 
double keywords, it does not implement them differently. Both generally resolve 
to double, though it is language dependent. This issue does seem to be specific 
to the Python implementation on your machine. I also get the same result as 
shown below on a 64-bit machine running Python 2.6.

Python 2.6 (r26:66714, Oct 17 2008, 13:40:29) 
[GCC 4.0.1 20050727 (Red Hat 4.0.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> repr(0.9)
'0.90000000000000002'

>From the python docs: http://docs.python.org/library/stdtypes.html
"Floating point numbers are implemented using double in C. All bets on their 
precision are off unless you happen to know the machine you are working with."


-----Original Message-----
From: Ted Dunning [mailto:[email protected]] 
Sent: Monday, January 19, 2009 8:58 AM
To: [email protected]
Subject: Re: Odd float values

Note the difference in values.  The first indicates conversion through a float 
representation.  Doubles have substantially more precision.  A good rule of 
thumb is that floats have about 7 digits, doubles about 17.

On Mon, Jan 19, 2009 at 8:04 AM, Esteve Fernandez <[email protected]>wrote:

> > And I get an output of 0.90000002
>
> It's not actually a problem in Thrift. As Ted pointed out, there's no 
> exact representation for floats in base 2. For example:
>
> python -c "f = 0.9; print repr(f)"
>
> gives 0.90000000000000002 here.
>
>

Reply via email to