include "math.m";
math:= load Math Math->PATH;
Infinity, NaN, MachEps, Pi, Degree : real;
INVAL, ZDIV, OVFL, UNFL, INEX : int;
RND_NR, RND_NINF, RND_PINF, RND_Z, RND_MASK: int;
getFPcontrol, getFPstatus: fn() : int;
FPcontrol, FPstatus: fn(r, mask: int) : int;
ilogb : fn(x: real) : int;
scalbn : fn(x: real, n: int) : real;
copysign : fn(x, s: real) : real;
finite, isnan : fn(x: real) : int;
nextafter : fn(x, y: real) : real;
fdim, fmin, fmax : fn(x, y: real) : real;
fabs : fn(x: real) : real;
ceil, floor : fn(x: real) : real;
remainder : fn(x, p: real) : real;
fmod : fn(x, y: real) : real;
modf : fn(x: real) :(int, real);
rint : fn(x: real) : real;
Description
These constants and functions provide control over rounding modes, exceptions, and other properties of floating point arithmetic.
Constants for non-overlapping single-bit masks are provided for use in arguments or return values. They stand for the five IEEE exceptions:
By default, INEX is quiet, OVFL, UNFL, and ZDIV are fatal, and rounding is to nearest even number. Limbo modules are entitled to assume this, and if they need to use quiet OVFL, UNFL, or ZDIV, they must either set and restore the control register or clearly document that the modules that call them must do so.
Constants (distinct bit patterns) are defined for interfacing with the floating point control word.
Any of the above constants can be set or extracted from the floating point control word using RND_MASK. Several examples follow:
ilogb (x)
|
The ilogb function returns the nearest integral logarithm base 2 of the absolute value of x: for positive finite x,
1 <= x*2-ilogb(x)< 2, and ilogb(-x) = ilogb(x).
|
scalbn (x, n)
|
The scalbn function returns a scaled power of two:
x *2n.
|
copysign (x, s)
|
The copysign function returns the magnitude of x and the sign bit of s.
|
nextafter (x, y)
|
The nextafter function returns the machine number nearest x closer to y.
|
finite (x)
|
The finite function returns is 0 if x is Nan or Infinity, and 1 otherwise.
|
isnan (x)
|
The isnan function returns 1 if x is Nan, and 0 otherwise.
|
fdim (x, y)
|
The fdim function equals x - y if x is greater than y, otherwise it is 0.
|
fmin (x, y)
|
The minimum of x and y.
|
fmax (x, y)
|
The maximum of x and y.
|
fabs (x)
|
The absolute value of x.
|
ceil (x)
|
The ceiling (round-up) of x.
|
floor (x)
|
The floor (round-down) of x.
|
fmod (x, y)
|
The fmod function conforms to the C language standard. It returns the value x - i *y for some i such that the remainder has the sign of x and magnitude less than the magnitude of y.
|
remainder (x, y)
|
The remainder function conforms to the IEEE standard which gives a remainder of magnitude no more than half the magnitude of y.
|
modf (x)
|
The modf function breaks x into integer and fractional parts returned in a tuple.
|
rint (x)
|
The rint function rounds to an integer, following the rounding mode specified in the floating point control word.
|
See Also
Limbo Math Module
infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights
reserved.