Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
Math


NAME

Math - mathematical constants and functions

SYNOPSIS

CONST e = 2.7182818284590452354;
CONST log2e = 1.4426950408889634074;
CONST log10e = 0.43429448190325182765;
CONST ln2 = 0.69314718055994530942;
CONST ln10 = 2.30258509299404568402;
CONST pi = 3.14159265358979323846;
CONST pidiv2 = 1.57079632679489661923;
CONST pidiv4 = 0.78539816339744830962;
CONST onedivpi = 0.31830988618379067154;
CONST twodivpi = 0.63661977236758134308;
CONST twodivsqrtpi = 1.12837916709551257390;
CONST sqrt2 = 1.41421356237309504880;
CONST sqrt1div2 = 0.70710678118654752440;


CONST domain = 0; CONST sing = 1; CONST overflow = 2; CONST underflow = 3; CONST errorcodes = 4; TYPE ErrorCode = SHORTINT; (* domain..underflow *) TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: ErrorCode; END; VAR errormsg: ARRAY errorcodes OF Events.Message; VAR error: Events.EventType;

PROCEDURE Sin(x: REAL) : REAL; PROCEDURE Cos(x: REAL) : REAL; PROCEDURE Tan(x: REAL) : REAL; PROCEDURE Arctan(x: REAL) : REAL; PROCEDURE Arctan2(y, x: REAL) : REAL; PROCEDURE Ln(x: REAL) : REAL; PROCEDURE Exp(x: REAL) : REAL; PROCEDURE Sqrt(x: REAL) : REAL;

PROCEDURE SinE(x: REAL; errors: RelatedEvents.Object) : REAL; PROCEDURE CosE(x: REAL; errors: RelatedEvents.Object) : REAL; PROCEDURE TanE(x: REAL; errors: RelatedEvents.Object) : REAL; PROCEDURE ArctanE(x: REAL; errors: RelatedEvents.Object) : REAL; PROCEDURE Arctan2E(y, x: REAL; errors: RelatedEvents.Object) : REAL; PROCEDURE LnE(x: REAL; errors: RelatedEvents.Object) : REAL; PROCEDURE ExpE(x: REAL; errors: RelatedEvents.Object) : REAL; PROCEDURE SqrtE(x: REAL; errors: RelatedEvents.Object) : REAL;

PROCEDURE SinL(x: LONGREAL) : LONGREAL; PROCEDURE CosL(x: LONGREAL) : LONGREAL; PROCEDURE TanL(x: LONGREAL) : LONGREAL; PROCEDURE ArctanL(x: LONGREAL) : LONGREAL; PROCEDURE Arctan2L(y, x: LONGREAL) : LONGREAL; PROCEDURE LnL(x: LONGREAL) : LONGREAL; PROCEDURE ExpL(x: LONGREAL) : LONGREAL; PROCEDURE SqrtL(x: LONGREAL) : LONGREAL;

PROCEDURE SinLE(x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL; PROCEDURE CosLE(x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL; PROCEDURE TanLE(x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL; PROCEDURE ArctanLE(x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL; PROCEDURE Arctan2LE(y, x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL; PROCEDURE LnLE(x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL; PROCEDURE ExpLE(x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL; PROCEDURE SqrtLE(x: LONGREAL; errors: RelatedEvents.Object) : LONGREAL;

DESCRIPTION

Math offers commonly used mathematical constants and functions. All functions are offered in four variants: for REAL and LONGREAL and with or without an errors parameter.

DIAGNOSTICS

Errors lead to events which are related to the errors parameter, or, if not given, directly to Events.Raise. Because these events are not ignored by default, this could cause program termination if error is not ignored or there doesn't exist a handler for it.

Following error codes are implemented:

domain
The argument x of the function is outside of the valid domain.
sing
Argument singularity, usually division by zero.
overflow
Overflow range exception, i.e. the result is too large to be representable.
underflow
Underflow range exception.

The current implementation defines an event handler for SysSignals.FPE to catch floating point exceptions. For this to work, the event handler for SysSignals.FPE must not be removed. The event handler of Math ignores exceptions caused by other modules.

SEE ALSO

IEEE
support of IEEE floating point format
RelatedEvents
error handling
SysSignals
floating point exception

CREDITS

The implementation of this module has been derived from the GNU C Library which, in turn, has been partially derived from sources of the University of California.
Edited by: borchert, last change: 2006/08/09, revision: 1.3, converted to HTML: 2006/08/09

Oberon || Library || Module Index || Search Engine || Definition || Module