Significant digit measuring

Discussion in 'C++' started by mrstephengross, May 5, 2005.

  1. Hi all... How can I find out the number of significant digits (to the
    right of the decimal place, that is) in a double? At least, I *think*
    that's what I'm asking for. For instance:


    0.103 --> 3
    0.0103 --> 4
    0.00103 --> 5
    0.000103 --> 6
    0.0000103 --> 7


    Thanks in advance!
    --Steve ()
     
    mrstephengross, May 5, 2005
    #1
    1. Advertising

  2. mrstephengross wrote:
    > Hi all... How can I find out the number of significant digits (to the
    > right of the decimal place, that is) in a double? At least, I *think*
    > that's what I'm asking for. For instance:
    >
    >
    > 0.103 --> 3
    > 0.0103 --> 4
    > 0.00103 --> 5
    > 0.000103 --> 6
    > 0.0000103 --> 7


    Actually, from what I remember, all numbers you have here have the same
    number of significant digits: 3, the leading (and trailing) zeros do not
    count as significant.

    And then there is no such thing as "significant digits" in a double. What
    may appear as 0.0103 to you (in the output), in fact is probably something
    like 0.010299999999999998 in the computer. IOW, all digits (16 or so) are
    significant in a 'double'.

    V
     
    Victor Bazarov, May 5, 2005
    #2
    1. Advertising

  3. >What may appear as 0.0103 to you (in the output), in fact is probably
    something
    like 0.010299999999999998 in the computer. IOW, all digits (16 or so)
    are
    significant in a 'double'.

    Darn! I suspected this was the case...

    --Steve
     
    mrstephengross, May 5, 2005
    #3
  4. mrstephengross

    Mark P Guest

    Victor Bazarov wrote:
    > mrstephengross wrote:
    >
    >> Hi all... How can I find out the number of significant digits (to the
    >> right of the decimal place, that is) in a double? At least, I *think*
    >> that's what I'm asking for. For instance:
    >>
    >>
    >> 0.103 --> 3
    >> 0.0103 --> 4
    >> 0.00103 --> 5
    >> 0.000103 --> 6
    >> 0.0000103 --> 7

    >
    >
    > Actually, from what I remember, all numbers you have here have the same
    > number of significant digits: 3, the leading (and trailing) zeros do not
    > count as significant.


    Mostly true, except that trailing zeros may be significant. Universally
    (I believe) 0.103000 is regarded as having 6 significant digits. For
    trailing zeros to the left of the decimal point it's ambiguous. 103000
    may have from 3 to 6 significant digits. According to one convention,
    one uses an overbar in such cases to mark the least significant digit.
     
    Mark P, May 5, 2005
    #4
    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. Fangs
    Replies:
    3
    Views:
    9,816
    darshana
    Oct 26, 2008
  2. Steve
    Replies:
    5
    Views:
    42,726
    Steve
    May 17, 2004
  3. Creatura
    Replies:
    0
    Views:
    298
    Creatura
    Jun 14, 2004
  4. a01lida
    Replies:
    2
    Views:
    715
    a01lida
    Nov 16, 2008
  5. SMH
    Replies:
    0
    Views:
    235
Loading...

Share This Page