|
|
|
Clear questions and runnable code get the best and fastest answer |
|
| PerlMonks |
Answer: How do I round a number? |
| ( #24343=categorized answer: print w/ replies, xml ) | Need Help?? |
|
Q&A > math > How do I round a number? contributed by fundflow
The guy asked to round a number, the simplest way
is (my highschool teacher would be proud now..):
$rounded = int ( $orig + 0.5 )
This approach floors any decimal portion less than 0.5, and rounds up (in value) any decimal portion greater than .5. That means the following:
|
|
||||||||||||||||||||||