Automatic Number Formatting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luftikus143
    New Member
    • Jan 2007
    • 97

    Automatic Number Formatting

    Hi there,

    I have several hundred statistical data sets, which are being displayed on the fly. The values can vary between 0.001 and 10000000 for the different sets.

    Now, when displaying some statistics like min and max, it is ok to strip the decimal places for most of the variables, but not for all.

    293873982.35 becomes 293873982
    0.04 becomes 0

    So, I implemented a series of IFs, to specify that if the value is between 1 and 10, than 1 decimal; if smaller as 1 than 2....

    But I wonder if there is a more elegant way to this. A small mathematical algorithm, which does it "better".

    Thanks for any ideas!
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    You mean significant figures? That's not mine, just someone else's function I found for you.

    Comment

    • luftikus143
      New Member
      • Jan 2007
      • 97

      #3
      You mean significant figures? That's not mine, just someone else's function I found for you.
      Interesting, could use this one for another part of the project. But no, I think more in the terms of "pay attention when to show how many decimals, depending on the "size" of the number".

      So, I think it's close to what I want, but not really.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        what about scientific display (like 1.234e+8 or 1.234e-2), maybe that's close to what you want?

        Comment

        • luftikus143
          New Member
          • Jan 2007
          • 97

          #5
          Originally posted by Dormilich
          what about scientific display (like 1.234e+8 or 1.234e-2), maybe that's close to what you want?
          No, thanks, but that's too complicated for "normal" users. :-)

          Comment

          • TheServant
            Recognized Expert Top Contributor
            • Feb 2008
            • 1168

            #6
            Originally posted by luftikus143
            Interesting, could use this one for another part of the project. But no, I think more in the terms of "pay attention when to show how many decimals, depending on the "size" of the number".

            So, I think it's close to what I want, but not really.
            I'm afraid the normal number rounding options of decimal places or significant figures are pretty much the only standard. If you show us your code already done we can maybe streamline it, but I doubt you will find a single function without making your own.

            Comment

            Working...