Originally Posted by
paul_uk
Am I right in saying that a double can hold a range of:
+/- 2.2 E-308 to +/- 1.8 E308 (8 bytes)
That is quite likely. You may want to verify the DBL_MAX on your system.
Originally Posted by
paul_uk
If so then should
1.797693134862315
907729305190789e+308
fit in a double variable
the above is 2^1024 which I did in the windows calculator, but when I do pow( 2, 1024 ) I get the 1.#INF00.
Any advice or help much appreciated
I don't suppose this is too much help, but I see similar results.
Code:
#include <stdio.h>
#include <math.h>
#include <float.h>
int main(void)
{
double value = log(DBL_MAX) / log(2.0);
printf("DBL_MAX = %f\n", DBL_MAX);
printf("value = %g\n", value);
value = pow(2.0, 1024.0);
printf("value = %g\n", value);
return 0;
}
/* my output
DBL_MAX = 1.797693134862315708000000000000000000000e+308
value = 1024
pow: OVERFLOW error
value = +INF
*/
I think this decimal approximation may hide the fact the pow(2,1024) is "one" more than the largest double. That is, if we could use hexadecimal floating-point constants, perhaps DBL_MAX is defined like this.
Code:
DBL_MAX 0X1.fffffffffffffP1023 // hex constant