Robert Kern wrote:
Paul McNett wrote:
One of my users has reported that my app is giving them scientific
notation instead of decimal notation for one specific value among many
that display properly. I am unable to reproduce on my end, and this is
the first I've heard of anything like this since the app's launch 2
years ago.
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?
Ideas?
Locales? Do you at last know the code that's responsible for formatting
the number?
I do use locale.format, but I use it for all numbers, and only one such number
displays in scientific notation - the rest are fine. Here's the code:
1355 def uom_string(self, val):
1356 """Given a decimal value, format it for string display."""
1357 if self.unit_of_measure == "inches":
1358 fd = dabo.dAppRef.getSSPref("fraction_display")
1359 if fd == "decimal":
1360 return '%s"' % locale.format("%.5f", val.normalize(), True)
1361 else:
1362 return '%s"' % fractions.getImperial(val)
1363 elif self.unit_of_measure == "millimeters":
1364 #return u"%s\u339C" % self.uom_round(val)
1365 return "%smm" % locale.format("%.1f", self.uom_round(val), True)
1366 else:
1367 raise ValueError, "Unit of Measure '%s' not recognized." %
self.unit_of_measure
In this case, self.unit_of_measure == "inches" and fd == "decimal".
Thanks
Paul
--
http://mail.python.org/mailman/listinfo/python-list