Documentation/Calc Functions/MROUND

From The Document Foundation Wiki
Jump to navigation Jump to search
Other languages:
English • ‎dansk



Function name:

MROUND

Category:

Mathematical

Summary:

Returns a number rounded to the nearest multiple of another number.

Syntax:

MROUND(Number; Multiple)

Returns:

Returns a real number which is the Number rounded to the nearest multiple of the Multiple.

Arguments:

Number is a real number or a reference to the cell containing that number which is to be rounded to the nearest multiple of Multiple.

Multiple is a real number or a reference to the cell containing that number whose nearest integer multiple the Number is to be rounded.

  • In case the Number is negative, its absolute value is considered for multiple selections and then the sign is multiplied to the result.
  • Sign of Multiple is ignored.
  • In case the Number is equally near to two consecutive multiples of Multiple, then higher absolute valued multiple is returned by the function. For eg., the Number is 11 the Multiple is 2 then both 10 and 12 are 1 unit from 11 then in such case the higher valued multiple selected, i.e. 12 in this case.

Additional details:

An alternative implementation would be Multiple * ROUND(Number/Multiple).

Examples:

Formula Description Returns
=MROUND(15.5;3) rounds 15.5 to nearest multiple of 3, i.e. 15.5 is closer to 15 (= 3*5) than to 18 (= 3*6) 15
=MROUND(1.4;0.5) rounds 1.4 to nearest multiple of 0.5, i.e. 1.4 is closer to 1.5 (= 0.5*3) than to 1.0 (= 0.5*2) 1.5
=MROUND(11;2) rounds 11 to nearest multiple of 2, i.e. 11 is equally near to 12 (= 2*6) and 10 (= 2*5) so taking higher value 12
=MROUND(-11;2) rounds -11 to nearest multiple of 2 but -11 is equally near to -12 (= 2*-6) and 10 (= 2*-5) so taking higher absolute valued multiple -12
=MROUND(-11;-2) rounds -11 to nearest multiple of 2,ignoring the sign -12
=MROUND(11;-2) rounds -11 to nearest multiple of 2, ignoring the sign 12

Related LibreOffice functions:

ROUND

ODF standard:

Section 6.17.4, part2

Equivalent Excel functions:

MROUND