in reply to Re^2: Trimming of the decimal part.
in thread Trimming of the decimal part.
So far I can remember my last encounter with true rounding in Perl the sprinf function is really the best, like you already said. For other rounding functions like floor() and ceil() the POSIX module can be used.
Update:
Just tested sprintf("%d") and it truncates like int(). A function which implements "normal" rounding, away from zero from .5 starting is:
sub round ($) { return sprintf("%.0f", shift); }
|
|---|