modulo container by number rounding roundingMethod
Number yields an integer, a number, or a complex. Container yields a container containing an integer, a number, or a complex. RoundingMethod is up, down, or to, toward, or towards zero, infinity, nearest, even, ceiling, or floor.
modulo steve by 17
modulo line 13 of bill by 100
The modulo command divides the value of container by the value of number and leaves the remainder of the division in container. The value in the container must be an integer, a number, or a complex and is replaced with the new value.
The remainder is calculated as follows:
remainder = container - number * roundingFunction ( container / number )
where roundingFunction is the function listed in the table below.
If no roundingMethod is specified, to floor is assumed.
The following table shows the correspondences among the various roundingMethods, rounding functions, and division operators:
rounding parameter |
function | operator | java.math.RoundingMode |
|---|---|---|---|
to ceiling |
ceil |
CEILING |
|
to floor |
floor |
div / mod |
FLOOR |
up / to infinity |
aug |
UP |
|
down / to zero |
trunc |
quot / rem |
DOWN |
to nearest |
round |
HALF_UP |
|
to even |
rint |
HALF_EVEN |
See the ceil, floor, aug, trunc, round, and rint functions for descriptions of how these rounding methods work.