next up previous contents
Next: Floating point comparisons Up: Tipical pitfalls with floating Previous: Tipical pitfalls with floating   Contents

Binary versus decimal

Consider the code fragment

%{}
program test
  real :: x=1.0E-4
  print*, x
end program test
We expect the answer to be , but in fact the program prints . Note that we did nothing but store and print! The ``anomaly'' comes from the fact that is converted (inexactly) to binary, then the stored binary value is converted back to decimal for printing.



Adrian Sandu 2001-08-26