|
Perl Class -
Free Perl Books
|
|
Written by Administrator
|
|
Friday, 17 April 2009 16:32 |
Posted by Matt Makarczyk (Systems Analyst/Programmer) on 04/15/2009 10:07:00 AM you can round floats using floor or ceil (part of POSIX) or use printf.. for example printf("%.3f", 3.1415) would print 3.142. However, I suggest you not test the outer limits or put a heap of faith in its accuracy. "Put in simple terms, you cannot rely on floating point to be free of rounding errors in some of the last few digits of precision. You're out at the limits there. Different versions of Perl, different architectures, and different alignment of planetary orbits will introduce minor rounding errors as the internal binary representation of floating point numbers manifests its limitations." Best- Matt Makarczyk __._
|