Mega Code Archive

 
Categories / Perl / Data Type
 

A program that illustrates round-off error problems in floating-point arithmetic

#!/usr/local/bin/perl  $value = 9.01e+21 + 0.01 - 9.01e+21;  print ("first value is ", $value, "\n");  $value = 9.01e+21 - 9.01e+21 + 0.01;  print ("second value is ", $value, "\n");