In an attempt to see what would happen in the case of a float underflow I found that I could make float numbers much smaller than FLT_MIN. I'm using xcode 5.1 on OS 10.9. The language dialect is gnu99.
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
int main(int argc, const char * argv[])
{
float underflow = FLT_MIN * 0.0000004;
printf("Float min is %f or %e.\nUnderflow is %f or %e\nMin float exp is %d.\n", FLT_MIN, FLT_MIN, underflow, underflow, FLT_MIN_10_EXP);
return 0;
}
Prints:
Float min is 0.000000 or 1.175494e-38.
Underflow is 0.000000 or 4.203895e-45
Min float exp is -37.
- Is there a more effective method of demonstrating the limits of data types?
- Why is FLT_MIN not actually the smallest float value? Are there other constants that I'm supposed to be using? After typing the previous question I found FLT_TRUE_MIN. What is this number?
FLT_TRUE_MIN
was introduced with C11, so formally would require using the "gnu11" dialect. – Chalkstone