Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
#include <float.h>

...

long double ld;
double d1;
double d2;
float f1;
float f2;

...

if(d1 > FLT_MAX) {
	/* Handle error condition */
} else {
	f1 = (float)d1;
}
if(ld > FLT_MAX) {
	/* Handle error condition */
} else {
	f2 = (float)ld;
}
if(ld > DBL_MAX) {
	/* Handle error condition */
} else {
	d2 = (double)ld;
}

References

Wiki Markup
\[WG14 N1124\] Section 
 (Extrapolate,
6.3.1.5
.2) (Cite C99) 
, "Real floating types"