#include <stdio.h>
#include <math.h>
#include <float.h>
int main()
{
float f = FLT_MIN;
float r = 1.0/f;
printf("Normal: f = %e, r = 1/f = %e\n", f, r);
int subf_i = 0x3;
f = *(float *)&subf_i;
r = 1.0/f;
float mul = r * f;
printf("Subnormal: f = %e, r = 1/f = %e, f*r = %e, 0*r = %e\n", f, r, mul, 0.0*r);
return 0;
}
输出
Normal: f = 1.175494e-38, r = 1/f = 8.507059e+37
Subnormal: f = 4.203895e-45, r = 1/f = inf, f*r = inf, 0*r = nan