Versions Compared

Key

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

...

This code attempts to reduce a floating point number to a denormalized value and then restore the value. This operation is very imprecise.

Code Block
bgColor#FFCCCC
langc
#include <stdio.h>
float x = 1/3.0;
printf("Original      : %e\n", x);
x = x * 7e-45;
printf("Denormalized? : %e\n", x);
x = x / 7e-45;
printf("Restored      : %e\n", x);

...

Don't produce code that could use denormalized numbers. If floats are producing denormalized numbers, use doubles instead.

Code Block
bgColor#ccccff
langc
#include <stdio.h>
double x = 1/3.0;
printf("Original      : %e\n", x);
x = x * 7e-45;
printf("Denormalized? : %e\n", x);
x = x / 7e-45;
printf("Restored      : %e\n", x);

...