Rounding floating point numbers¶
-
class
oxrse.FloatRounder(round_towards_zero=False)¶ Rounds floating point numbers.
Two rounding modes are available: rounding to the nearest integer (default) and rounding towards zero (to enable set
round_towards_zerotoTrue).-
round(number)¶ Rounds the given
numberand returns the result (as a float).The method really doesn’t like rounding “1.23” or “2.34”, and will raise a
ValueErrorif asked to do so.
-