scientific notation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • masoud bayan

    scientific notation

    I have some values in type of double such 0.00009 , 0.0000007, when I want
    to show them in a text box and convert them to string they are changed to
    scientific notation while I want to show them as they are.
    I tried to use tostring("f") but it needs to have a precision number after
    *f* which will cause always have fix number of characters (for example if
    use f10 then 0.09 is converted to 0.09000000 while I need to show it as
    0.09).
    do you any suggestion of how I can convert such a numbers to string and show
    them as they are not as scientific notation?

    Thanks for any feedback


  • George Yefchak

    #2
    Re: scientific notation

    You may be able to use the "g" format specifier if you have a maximum number
    of decimal places you could accept. For anything more complex (e.g.,
    0.00009, but also 0.023), you'll need to write some code to choose between
    various formatting strings depending on the value of your variable.

    --George

    "masoud bayan" <masoud_bayan@h otmail.com> wrote in message
    news:ecWGt3hsEH A.376@TK2MSFTNG P09.phx.gbl...[color=blue]
    > I have some values in type of double such 0.00009 , 0.0000007, when I want
    > to show them in a text box and convert them to string they are changed to
    > scientific notation while I want to show them as they are.
    > I tried to use tostring("f") but it needs to have a precision number[/color]
    after[color=blue]
    > *f* which will cause always have fix number of characters (for example if
    > use f10 then 0.09 is converted to 0.09000000 while I need to show it as
    > 0.09).
    > do you any suggestion of how I can convert such a numbers to string and[/color]
    show[color=blue]
    > them as they are not as scientific notation?
    >
    > Thanks for any feedback
    >
    >[/color]


    Comment

    • Josip Medved

      #3
      Re: scientific notation

      >I have some values in type of double such 0.00009 , 0.0000007, when I want[color=blue]
      > to show them in a text box and convert them to string they are changed to
      > scientific notation while I want to show them as they are.
      > I tried to use tostring("f") but it needs to have a precision number
      > after
      > *f* which will cause always have fix number of characters (for example if
      > use f10 then 0.09 is converted to 0.09000000 while I need to show it as
      > 0.09).
      > do you any suggestion of how I can convert such a numbers to string and
      > show
      > them as they are not as scientific notation?[/color]

      try ToString("0.### #####")...

      --
      Pozdrav,
      Josip Medved, MCSD
      A personal website dedicated to technology, software development, and practical tools.


      Comment

      Working...