The Standard ML Basis Library


The IntInf structure

The optional IntInf structure is one of the possible implementations of the INTEGER interface. In addition to the INTEGER operations, it provides some operations useful for programming with arbitrarily large integers (bignums). Note that operations in IntInf that return a value of type IntInf.int will never raise the Overflow exception.


Synopsis

signature INT_INF
structure IntInf : INT_INF

Interface

include INTEGER
val divMod : (int * int) -> (int * int)
val quotRem : (int * int) -> (int * int)
val pow : (int * Int.int) -> int
val log2 : int -> Int.int

Description

include INTEGER

divMod (i, j)
returns the pair (i div j, i mod j), but is likely to be more efficient than computing both components separately. Raises Div if j = 0.

quotRem (i, j)
returns the pair (i quot j, i rem j), but is likely to be more efficient than computing both components separately. Raises Div if j = 0.

pow (i, j)
returns the result of raising i to the j'th power. When j < 0 and i is non-zero, the result is 0; when j < 0 and i is zero, exception Domain is raised. We define that pow(0, 0) is 1.

log2 i
returns the truncated base-2 logarithm of its argument, i.e., returns the largest integer k for which pow(2, k) <= i. Raises Domain if i <= 0. Raises Overflow if the result is not representable as an Int.int.


Discussion

If an implementation provides the IntInf structure, then the type LargeInt.int must be the same as IntInf.int type.

See Also

INTEGER, LargeInt

[ INDEX | TOP | Parent | Root ]

Last Modified April 11, 1996
Copyright © 1996 AT&T