It sounds like this is a representation issue. Floats and doubles are
approximate, and therefore not so good for holding money values. The
easiest thing to do is have your total in cents and do the
appropriate conversions elsewhere.
-Bryan
On Jan 19, 2009, at 12:21 AM, Phillip Oldham wrote:
I'm not doing any conversion of types as far as I know. Defining
the attr as a double in thrift, then in python:
p = Price()
p.total = 0.9
client.setPrice(p)
And for the server:
def setPrice(self, p):
print p
And I get an output of 0.90000002
Sent from my iPhone
On 19 Jan 2009, at 02:30, Ted Dunning <[email protected]> wrote:
What happens when you convert 0.9 to float and back to double again?
Also what happens if you pass your value through thrift via a
double instead of a float.
Remember that 0.9 has no exact representation in base 2.
Sent from my iPhone
On Jan 18, 2009, at 14:13, Phillip B Oldham
<[email protected]> wrote:
I've written both a client and server in python. When I pass an
object
which contains a float (eg: 0.9) from the client to the server the
value changes (eg: the server prints 0.90000000000000002). I'm using
the latest svn version.
Am I missing something obvious?
--
Phillip B Oldham
[email protected]
+44 (0) 7525 01 09 01