Re: Unexpected scientific notation

Discussion in 'Python' started by Paul McNett, Jan 8, 2009.

  1. Paul McNett

    Paul McNett Guest

    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
    Paul McNett, Jan 8, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ville Ahonen

    No scientific notation?

    Ville Ahonen, Oct 19, 2004, in forum: C++
    Replies:
    2
    Views:
    445
    Mike Wahler
    Oct 19, 2004
  2. Dustan

    Scientific Notation

    Dustan, Dec 4, 2005, in forum: Python
    Replies:
    7
    Views:
    13,453
    Dustan
    Dec 4, 2005
  3. grinder

    reguarding scientific notation

    grinder, Aug 28, 2006, in forum: C Programming
    Replies:
    7
    Views:
    455
    Knemon
    Aug 29, 2006
  4. asdf
    Replies:
    2
    Views:
    546
    Rolf Magnus
    Oct 21, 2006
  5. Paul McNett

    Unexpected scientific notation

    Paul McNett, Jan 8, 2009, in forum: Python
    Replies:
    10
    Views:
    671
    Mark Dickinson
    Jan 9, 2009
Loading...

Share This Page