Re: [PBML] int() function acting wierd
- Mike Southern wrote:
> I suppose to get round the problem, instead of $num = ($x * 100) you couldCongratulations. You have just stumbled across a field of study called
> use $num = ($x * 1000000) / 1000 but is there a more elegant perl function
> for that?
Numerical Analysis <http://en.wikipedia.org/wiki/Numerical_Analysis>.
You be better off with:
$num = int(( $x + $epsilon ) * 100 );
where $epsilon < Error in $x
Perl elegant? Perl is like your grandfather's garage. Sure, he kept most
of it tidy to please your grandmother but there was always one corner
where you could find the most amazing junk. And some days, when you were
particularly lucky, he'd show you how it worked.
Just my 0.00000002 million dollars worth,
"Probability is now one. Any problems that are left are your own."
SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_
* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/