DescTools (version 0.99.8.1)

Mround: Round to Multiple

Description

Returns a number rounded to the desired multiple.

Usage

Mround(x, multiple)

Arguments

x
numeric. The value to round.
multiple
numeric. The multiple to which the number is to be rounded.

Value

  • the rounded value

Details

Mround rounds up, away from zero, if the remainder of dividing number by multiple is greater than or equal to half the value of multiple.

See Also

round

Examples

Run this code
Mround(10, 3)     # Rounds 10 to a nearest multiple of 3 (9)
Mround(-10, -3)   # Rounds -10 to a nearest multiple of -3 (-9)

Mround(1.3, 0.2)  # Rounds 1.3 to a nearest multiple of 0.2 (1.4)
Mround(5, -2)     # Returns an error, because -2 and 5 have different signs    

Mround(c(1.92, 45.38, 0.831125), 0.05)

Run the code above in your browser using DataLab