Skip to content

Instantly share code, notes, and snippets.

@phc15
Last active February 18, 2021 07:26
Show Gist options
  • Save phc15/56dad9900d8e71c625869c06d0d5b3ab to your computer and use it in GitHub Desktop.
Save phc15/56dad9900d8e71c625869c06d0d5b3ab to your computer and use it in GitHub Desktop.
float fl, fltest, last;
fl = 0.0; // check if the float number is NaN
while(fl == 0.0) {
last = fltest;
fltest += 1.111e+31; // sign bit 1 + exponent 8 bits + mantissa 23 bits
if((fl = (fl + fltest) + (-fltest)) != 0.0) { // 0.0 +∞ + (-∞) == NaN
break;
}
}
printf("Unsigned float max: %e", last);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment