Number of Significant Digits in a Float

This is a discussion on Number of Significant Digits in a Float within the C++ Programming forums, part of the General Programming Boards category; I've got some numbers and I'm trying to determine if rounding will occur if I store them as the type ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    197

    Number of Significant Digits in a Float

    I've got some numbers and I'm trying to determine if rounding will occur if I store them as the type float. The numbers have six digits( e.g. 1.23456e001). How can I determine the number of significant digits that are stored in a float?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    There is a define in <float.h> [or <cfloat>] called FLT_DIG (DBL_DIG or LDBL_DIG for double and long double respectively).

    I'm not sure if this a "best case" or "worst case" situation.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. decimal to number if digits in different bases
    By jorgejags in forum C Programming
    Replies: 21
    Last Post: 09-24-2008, 12:55 PM
  2. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  3. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  4. help me
    By warthog89 in forum C Programming
    Replies: 11
    Last Post: 09-30-2006, 08:17 AM
  5. Newton-Raphson number squaring method/pointers
    By inakappeh in forum C Programming
    Replies: 2
    Last Post: 08-29-2001, 11:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21