Perl Monk, Perl Meditation | |
PerlMonks |
Re: Re: Fix floats like you do in your headby tachyon (Chancellor) |
on Dec 25, 2002 at 00:11 UTC ( [id://222149]=note: print w/replies, xml ) | Need Help?? |
Great links. As you say this is not a ceil() or a round() function which behaves in strict mathematical terms, nor does it attempt to solve any of the problems associated with doing decimal fp arithmetic in binary. The beauty/purpose of it is that is does what a human tends to do. I see 0.9999999 and think 1 or 0.00999999 and think 0.01 which is what you get with the approx() function. I did call it approx() rather than exact(), actually() or really() ;-). I had it in mind for simple display functions not anything serious. It also only works on the decimal fraction but could be extended to work on the integer component so 999999.9 or 1000000.1 would become 1,000,000. cheers tachyon s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In Section
Cool Uses for Perl
|
|