Formating numbers

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

    Formating numbers

    Im having this problem with Formatting numbers.......I n any case I
    declare a variable intvalue as double....when i look at what values
    are being written out in the text file i see two different values.the
    first value is 0.01 and the second value is 0.0099999998 how can I
    format the number to 2 decimal places???
  • rowe_newsgroups

    #2
    Re: Formating numbers

    On Oct 31, 9:10 am, cmdolcet69 <colin_dolce... @hotmail.comwro te:
    Im having this problem with Formatting numbers.......I n any case I
    declare a variable  intvalue as double....when i look at what values
    are being written out in the text file i see two different values.the
    first value is 0.01 and the second value is 0.0099999998 how can I
    format the number to 2 decimal places???
    Math.Round()?

    Thanks,

    Seth Rowe [MVP]

    Comment

    • cmdolcet69

      #3
      Re: Formating numbers

      On Oct 31, 9:15 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
      On Oct 31, 9:10 am, cmdolcet69 <colin_dolce... @hotmail.comwro te:
      >
      Im having this problem with Formatting numbers.......I n any case I
      declare a variable  intvalue as double....when i look at what values
      are being written out in the text file i see two different values.the
      first value is 0.01 and the second value is 0.0099999998 how can I
      format the number to 2 decimal places???
      >
      Math.Round()?
      >
      Thanks,
      >
      Seth Rowe [MVP]http://sethrowe.blogsp ot.com/
      Will that solve my issue???? is this normal behavior

      Comment

      • Armin Zingler

        #4
        Re: Formating numbers

        "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb
        Im having this problem with Formatting numbers.......I n any case I
        declare a variable intvalue as double....when i look at what values
        are being written out in the text file i see two different
        values.the first value is 0.01 and the second value is 0.0099999998
        how can I format the number to 2 decimal places???
        How do you convert the number to a String? If you don't do it on your own
        (by passing it to a method that does the conversion), do it now:
        value.ToString( "0.00")

        The documentation contains chapters about this once again:
        Microsoft technical documentation for older versions of products, services and technologies.



        Armin

        Comment

        • Cor Ligthert[MVP]

          #5
          Re: Formating numbers

          Use decimal instead of double as double is a math value.


          "cmdolcet69 " <colin_dolcetti @hotmail.comsch reef in bericht
          news:1defa026-423e-4aaa-9ec5-4b531407257a@c3 6g2000prc.googl egroups.com...
          On Oct 31, 9:15 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
          On Oct 31, 9:10 am, cmdolcet69 <colin_dolce... @hotmail.comwro te:
          >
          Im having this problem with Formatting numbers.......I n any case I
          declare a variable intvalue as double....when i look at what values
          are being written out in the text file i see two different values.the
          first value is 0.01 and the second value is 0.0099999998 how can I
          format the number to 2 decimal places???
          >
          Math.Round()?
          >
          Thanks,
          >
          Seth Rowe [MVP]http://sethrowe.blogsp ot.com/
          Will that solve my issue???? is this normal behavior


          Comment

          • Kevin S Gallagher

            #6
            Re: Formating numbers

            or Value.ToString( "F2")

            "Armin Zingler" <az.nospam@free net.dewrote in message
            news:urxgDy1OJH A.3748@TK2MSFTN GP04.phx.gbl...
            "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb
            >Im having this problem with Formatting numbers.......I n any case I
            >declare a variable intvalue as double....when i look at what values
            >are being written out in the text file i see two different
            >values.the first value is 0.01 and the second value is 0.0099999998
            >how can I format the number to 2 decimal places???
            >
            How do you convert the number to a String? If you don't do it on your own
            (by passing it to a method that does the conversion), do it now:
            value.ToString( "0.00")
            >
            The documentation contains chapters about this once again:
            Microsoft technical documentation for older versions of products, services and technologies.

            >
            >
            Armin

            Comment

            Working...