Round a floating point number

number:round(FLOAT $number, INT $decimal_points=0, STRING $mode="")

number:round(19.9)
#=> 20

number:round(19.46)
#=> 19

number:round(10.46,1)
#=> 10.5

number:round(10.46,2)
#=> 10.46

number:round(16)
#=> 16

number:round(16,2)
#=> 16.0

number:round(19.9)
#=> 20

number:round(99.5, 0, 'up')
#=> 100

number:round(99.5, 0, 'down')
#=> 99

number:round(99.5, 5, 'even')
#=> 99.5

number:round(99.5, 2, 'odd')
#=> 99.5

number:round(1.9879, 3)
#=> 1.988

number:round(1.9879, 3, 'up')
#=> 1.988

Copyright ©2013-2022 SunSed®. All rights reserved.