Does double represent numbers as small as 10^-308?

This is a discussion on Does double represent numbers as small as 10^-308? within the C Programming forums, part of the General Programming Boards category; If yes, then how do I output such a small number using the 'printf' function?...

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

    Does double represent numbers as small as 10^-308?

    If yes, then how do I output such a small number using the 'printf' function?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    Erm, what does
    printf( "%f\n", mynumber );
    do for you?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,208
    The actual answer is "maybe". Some floating point formats will represent values as small as 1E-308, others will not.

    Try using the %g format specifier rather than %f in the printf format string.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    197
    Using printf( "%f\n", mynumber ); only gives me a precision of 10^-6.

    Thanks. The %g format seems to have fixed the issue.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  2. double, NaN, and super small numbers
    By nbo10 in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 06:50 PM
  3. expected primary expression
    By mju4t in forum C Programming
    Replies: 2
    Last Post: 03-27-2007, 06:59 PM
  4. Unknown Math Issues.
    By Sir Andus in forum C++ Programming
    Replies: 1
    Last Post: 03-06-2006, 05:54 PM
  5. Big (and small) numbers...
    By swif in forum C Programming
    Replies: 6
    Last Post: 04-22-2005, 12:21 PM

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