Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Unexpected scientific notation

Thread Tools

Re: Unexpected scientific notation

Paul McNett
Posts: n/a
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." %

In this case, self.unit_of_measure == "inches" and fd == "decimal".


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unexpected scientific notation Paul McNett Python 10 01-09-2009 07:14 PM
How to represent the scientific notation? asdf C++ 2 10-21-2006 04:12 PM
reguarding scientific notation grinder C Programming 7 08-29-2006 09:26 PM
Scientific Notation Dustan Python 7 12-04-2005 01:56 PM
No scientific notation? Ville Ahonen C++ 2 10-19-2004 10:08 PM