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.

Code Block
bgColor#FFCCCC
#include <stdio.h>
float x = 1/3.0f;
System.out.println("Original      : " + x);
x = x * 7e-45f;
System.out.println("Denormalized? : " + x);
x = x / 7e-45f;
System.out.println("Restored      : " + x);

...

Do not use code that could use denormalized numbers. When calculations using float produce denormalized numbers, use of double may provide sufficient precision.

Code Block
bgColor#ccccff
#include <stdio.h>
double x = 1/3.0;
System.out.println("Original      : " + x);
x = x * 7e-45;
System.out.println("Denormalized? : " + x);
x = x / 7e-45;
System.out.println("Restored      : " + x);

...