Next Previous Up Top Contents Index

6.3 The MACHINE-WORDS module

6.3.4 Signed double word operations

For all of the following functions, all arguments that are specified as being specialized to <machine-word> accept an instance of <abstract-integer>, which is then coerced to a <machine-word> before performing the operation.

d%floor/

Function

d%floor/ (dividend-low :: machine-word, dividend-high :: machine-word, divisor :: machine-word) => (quotient :: machine-word, remainder :: machine-word)

d%ceiling/

Function

d%ceiling/ (dividend-low :: machine-word, dividend-high :: machine-word, divisor :: machine-word) => (quotient :: machine-word, remainder :: machine-word)

d%round/

Function

d%round/ (dividend-low :: machine-word, dividend-high :: machine-word, divisor :: machine-word) => (quotient :: machine-word, remainder :: machine-word)

d%truncate/

Function

d%truncate/ (dividend-low :: machine-word, dividend-high :: machine-word, divisor :: machine-word) => (quotient :: machine-word, remainder :: machine-word)

d%divide

Function

d%divide (dividend-low :: machine-word, dividend-high :: machine-word, divisor :: machine-word) => (quotient :: machine-word, remainder :: machine-word)

The functions d%divide, d%floor/, d%ceiling/, d%round/, and d%truncate/ all perform signed division of the double word dividend by the divisor, returning a quotient and remainder such that

(quotient * divisor + remainder = dividend)

When the division is inexact (in other words, when the remainder is not zero), the kind of rounding depends on the operation:

d%floor/

The quotient is rounded toward negative infinity.

d%ceiling/

The quotient is rounded toward positive infinity.

d%round/

The quotient is rounded toward the nearest integer. If the mathematical quotient is exactly halfway between two integers then the resulting quotient is rounded to the nearest even integer.

d%truncate/

The quotient is rounded toward zero.

d%divide

If both operands are non-negative, then the quotient is rounded toward zero. If either operand is negative, then the direction of rounding is unspecified, as is the sign of the remainder.

For all of these functions, an error is signaled if the value of the divisor is zero or if the correct value for the quotient exceeds the machine word range.


Common Dylan and Functional Extensions - 31 Mar 00

Next Previous Up Top Contents Index