divide 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.
divide total by 3
divide line 3 of steve by 10
The divide command divides the value of container by the value of number and leaves the result in container. The value in the container must be an integer, a number, or a complex and is replaced with the new value.
If a roundingMethod is given, the result is rounded to an integer. 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.
The following example prints the percentage represented by a fraction of two numbers passed in as parameters:
on percent steve, bill divide steve by bill put trunc(steve * 100) & "%" end percent
HyperTalk does not support the rounding keyword.