﻿ ROUNDDOWN(), ROUNDUP()

# ROUNDDOWN(), ROUNDUP()

The ROUNDDOWN() function returns an integer value rounded towards zero in a given increment. The ROUNDUP() function returns an integer value rounded away from zero in a given increment.

Format

ROUNDDOWN(value, increment)

ROUNDUP(value, increment)

where

 value is a numeric value to be rounded.

 increment is the integer rounding increment.

The ROUNDDOWN() function returns the integer value rounded towards zero in steps of increment. It is equivalent to use of

IDIV(value, increment) * increment

The ROUNDUP() function returns the integer value rounded away from zero in steps of increment. For a positive value it is equivalent to use of

IDIV(value + increment - 1, increment) * increment

or, for a negative value

IDIV(value - increment + 1, increment) * increment

If increment is less than one, the function returns zero.

Example

FOR I = -10 TO 10

DISPLAY I, ROUNDDOWN(I, 3), ROUNDUP(I,3)

NEXT I

The above loop displays:

-10  -9   -12

-9   -9   -9

-8   -6   -9

-7   -6   -9

-6   -6   -6

-5   -3   -6

-4   -3   -6

-3   -3   -3

-2   0    -3

-1   0    -3

0    0    0

1    0    3

2    0    3

3    3    3

4    3    6

5    3    6

6    6    6

7    6    9

8    6    9

9    9    9

10   9    12