in reply to How do I round up a number?
will produce@num = (6, 5.3, 8.5, 9.5000000001, 3.84, 4.51); foreach $num (@num) { print qq{original: $num\n}; $new = sprintf "%.0f\n",$num; print qq{new: $new}; }
Not quite right for the 8.5, but it is close for the rest, and that can be compared differently.original: 6 new: 6 original: 5.3 new: 5 original: 8.5 new: 8 original: 9.5000000001 new: 10 original: 3.84 new: 4 original: 4.51 new: 5
Originally posted as a Categorized Answer.
|
|---|