greatest floating point number?

This is a discussion on greatest floating point number? within the C++ Programming forums, part of the General Programming Boards category; I know of LONG_MAX for intergers, but what is the identifer for the largest and smallest floats and which header ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    33

    greatest floating point number?

    I know of LONG_MAX for intergers, but what is the identifer for the largest and smallest floats and which header file is it in ?

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    i can't remember the name of the constant, but the header file is called 'limits.h' and if you browse through it the answer should be easy to find.

  3. #3
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    float
    32 bits
    1.18x10^-38 < |X| < 3.40x10^38 Scientific (7-digit) precision)


    double
    64 bits
    2.23x10^-308 < |X| < 1.79x10^308 Scientific (15-digit precision)


    long double
    80 bits
    3.37x10^-4932 < |X| < 1.18x10^4932 Financial (18-digit precision)
    Last edited by Davros; 10-19-2002 at 10:04 PM.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >but the header file is called 'limits.h'
    float.h, or cfloat for new C++ headers.

    >float
    >32 bits
    >1.18x10^-38 < |X| < 3.40x10^38 Scientific (7-digit) precision)
    The size of float, double, and long double are implementation-defined.
    Code:
    #include <iostream>
    #include <cfloat>
    
    int main()
    {
      std::cout<< FLT_MAX <<'\n'<< DBL_MAX <<'\n'<< LDBL_MAX <<std::endl;
     
      return 0;
    }
    -Prelude
    My best code is written with the delete key.

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    I know 32-bit flaoting number representation.
    Are the double and long double the same?

  6. #6
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    I think prelude is right, sizes are implementation defined. The values I gave will be probable.

    I guess C++ standard will only goes as far as:

    sizeof(double) <= sizeof(long double)

    The other words, they may be or may not be equal.

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    On my machine, FLT_MAX is the same as yours, Davros: 3.40282e+38.

    DBL_MAX = 1.79769e+308 and LDBL_MAX = 1.18973e+4932, again, on my machine.

    A long double is an eensy bit larger.

    -Skipper
    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

  8. #8
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Code:
    #undef max
    #include <limits>
    
    //To obtain the maximum values
    std::numeric_limits<float>::max() 
    std::numeric_limits<double>::max()
    std::numeric_limits<long double>::max()
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. floating point number printf/string formating
    By stanlvw in forum C++ Programming
    Replies: 2
    Last Post: 04-22-2009, 05:41 PM
  2. Decimal places on Floating point number
    By manutdfan in forum C Programming
    Replies: 1
    Last Post: 10-29-2006, 12:56 PM
  3. floating point variables in edittext controls
    By dootickle in forum Windows Programming
    Replies: 3
    Last Post: 04-15-2004, 12:15 PM
  4. Replies: 2
    Last Post: 09-10-2001, 01:00 PM

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