Post
Topic
Board Bitcoin Discussion
Re: TradeHill API was coded by amateurs
by
semarjt
on 20/06/2011, 03:35:44 UTC
Sending decimal numbers as numbers invites clients to interpret them as floats and thereby introduce rounding errors. It's not a bad idea to transfer fixed point decimal numbers as strings.

Correct. This is actually a feature borne out of wisdom dealing with lots of different languages and runtimes which may not support floating point math accurately or as expected when doing conversions to other types.

gigi is the idiot.

EDIT: and just to clarify, using a string type let's you, the API user, determine how to re-cast and interpret the value rather than dealing with side effects of some implementation which tries to "do the right thing" by default.


This is all correct and makes sense. I would also like to add that in order to serialize a decimal.Decimal() (which i can almost guarantee they are using).
 You have to cast it to a native type beforehand. Your choices are: str(), int() or float().

The choice is obvious