philip at semanchuk.com
Thu Aug 12 23:25:07 CEST 2010
On Aug 12, 2010, at 4:43 PM, Bradley Hintze wrote:
> Hi all.
> Is there a way I can keep my floating point number as I typed it? For
> example, I want 34.52 to be 34.52 and NOT 34.5200000002.
Use the Decimal type instead. It's not as convenient as float, but it
will give you a consistent representation of your numbers.
The behavior of floating point numbers surprises a lot of people and
has been discussed at length a number of times here (and elsewhere).
If you're in the mood for EXTREMELY thorough coverage of the subject,
you can read this:
There's a gentler discussion of it here:
More information about the Python-list