Mark Dickinson wrote:
On Jan 8, 1:00 am, Paul McNett <p...@ulmcnett.com> wrote:
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?

Ideas?

[I thought I replied to this earlier, but the post isn't showing up.
So here it is again.]

LOL!

I suspect it's your use of the Decimal normalize() method that's
causing
this.  Trailing zeros on Decimal instances are significant, so
Decimal('30.0'), Decimal('30') and Decimal('3E+1') are considered
distinct (though they all have the same value).  The normalize method
strips all trailing zeros, turning Decimal('30.0') into Decimal('3E
+1').

One way to get around this is to add 0 after normalizing: this will
make sure that scientific notation is used only for very large
or small numbers, as usual.

Thank you for the insight. I believe the problem is with my use of normalize(), but I still can't figure out why I can't reproduce the issue in my running app. But I can see in the interpreter that printing Decimal("30.0").normalize() results in "3E+1".

Paul
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to