Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Rounding off numbers

by Tanalis (Curate)
on Apr 20, 2006 at 14:36 UTC ( #544614=note: print w/ replies, xml ) Need Help??


in reply to Re: Rounding off numbers
in thread Rounding off numbers

.. though it's important to remember that simply casting a float to an int, thus:

my $float = 2.744; my $int = int $float;
results in the decimal part of the number simply being truncated, giving an integer value with the above example of 2, not 3, which is possibly not what's expected.

Update: Although, of course, adding the 0.5 to the number solves the problem nicely. Didn't see that in the post until just now ..


Comment on Re^2: Rounding off numbers
Download Code
Re^3: Rounding off numbers
by sgifford (Prior) on Apr 20, 2006 at 14:37 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://544614]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2015-07-03 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls