Unexpected scientific notation
p at ulmcnett.com
Thu Jan 8 05:23:52 CET 2009
[Some day hopefully I'll remember to change the to: address to python-list at python.org
instead of the original sender. I always end up sending the first reply to the
sender, then going "oops, forgot to hit 'reply-all'", and sending another copy to the
Ben Finney wrote:
> Paul McNett <p at ulmcnett.com> writes:
>> The app bundles python 2.5.2 using py2exe.
>> It displays '3E+1' instead of '30.0'.
>> As I can't reproduce I'm looking for an idea brainstorm of what
>> could be causing this. What would be choosing to display such a
>> normal number in scientific notation?
> As I understand it, the Python string formatting operations
> use the operating system's C library to perform (some of?) the
> The different behaviours you see might therefore be caused by
> different C libraries in the operating system.
> To avoid these and related problems, I would avoid floating point
> wherever possible and use the ‘Decimal’ type for representing decimal
Thanks. I forgot to mention that all numbers are already instances of
decimal.Decimal, not float. As I mentioned in a prior message, they do go through a
locale.format() call to display the value.
More information about the Python-list