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 ?
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 ?
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.
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 09:04 PM.
>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.
-PreludeCode:#include <iostream> #include <cfloat> int main() { std::cout<< FLT_MAX <<'\n'<< DBL_MAX <<'\n'<< LDBL_MAX <<std::endl; return 0; }
My best code is written with the delete key.
I know 32-bit flaoting number representation.
Are the double and long double the same?
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.
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
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