next node: Real,
prev node: Int,
up to node: Subsystem Numbers


Nat

Natural numbers, bounded

Signature of Nat

List of Import References :
See BOOL
See DENOTATION

SIGNATURE Nat

$Date: 2011-09-28 10:10:50 +0200 (Mi, 28. Sep 2011) $ ($Revision: 713 $)

IMPORT BOOL ONLY bool
       DENOTATION ONLY denotation

-- $The free type$
TYPE nat == 0
            succ(pred:nat)

Constants

It is not possible in OPAL to write down all numbers directly. The numbers used most often are introduced by the follwoing declarations:

The smallest and biggest nat number

The maximum depends on the size of an unsigned long on the target platform. If an unsigned long has n bits, the largest nat is of size 2^(n-1)-1. On a 32 bit architecture, n is typically 32 and 64 on 64 bit architectures.

FUN min max: nat

Other numbers are represented as denotations and a conversion function !: "1995"!, "4711"!, ... This function aborts if the denotation contains characters which are not digits (not even spaces are allowed!).

FUN ! : denotation -> nat

Calculating

The fundamental operations.

FUN + - * : nat ** nat -> nat

Division (5/3 = 5 div 3 ==> 1)

FUN /  : nat ** nat -> nat
FUN div: nat ** nat -> nat

Remainder of division: 5 % 3 = 5 mod 3 ==> 2

FUN %   : nat ** nat -> nat
FUN mod : nat ** nat -> nat

Power

FUN ^ pow: nat ** nat -> nat

Faster operations for double and half

FUN double : nat -> nat
FUN half:  nat -> nat

Minimum and maximum

FUN min max : nat ** nat -> nat

Tests on natural numbers

Evenness and oddness

FUN even? odd? : nat -> bool

Equality, inequality

FUN = |= : nat ** nat -> bool

Comparisons

FUN <=  >= < >  : nat ** nat->bool

Bracketings

multiplying operators have higher priority than adding operators

/$ BRACKET RIGHT [+,-] [*,/,%,div,mod] $/
/$ BRACKET LEFT [*,/,%,div,mod] [+,-] $/

arithmetic operators associtate to the left (but not ^!)

/$ BRACKET LEFT [+,-] [+,-] $/
/$ BRACKET LEFT [*,/,%,div,mod] [*,/,%,div,mod] $/

power has highest priority

/$ BRACKET RIGHT [+,-,*,/,%,div,mod] [^] $/
/$ BRACKET LEFT [^] [+,-,*,/,%,div,mod] $/


next node: Real,
prev node: Int,
up to node: Subsystem Numbers