next node: Nat,
prev node: Subsystem Numbers,
up to node: Subsystem Numbers


Int

Integer numbers, bounded (from -1.073.741.824 to 1.073.741.823 )

Signature of Int

List of Import References :
See BOOL
See DENOTATION

SIGNATURE Int

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

IMPORT BOOL ONLY bool
       DENOTATION ONLY denotation

Integer numbers have the same functions as natural numbers. In addition, there are functions which take the sign into account, like unary minus -, abs and the test functions neg?, zero? and pos?.

The sort int

SORT int

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 int number

FUN min max: int

Other numbers are represented as denotations and a conversion function !: "1995"!, "-4711"!, ... The first character may be a minus sign, all other characters must be decimal digits. This function aborts if this condition is not met.

FUN ! : denotation -> int

Calculating

The fundamental operations.

FUN + - * : int ** int -> int

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

FUN / : int ** int -> int
FUN div : int ** int -> int   

Remainder of division(1): 5 % 3 = 5 mod 3 ==> 2

FUN %     : int ** int -> int
FUN mod   : int ** int -> int

Power

FUN ^ pow: int ** int -> int

Faster operations for special cases

FUN succ: int -> int
FUN pred: int -> int
FUN double : int -> int
FUN half:  int -> int

Minimum and maximum

FUN min max     : int ** int -> int

Sign of argument -1, 0 or +1

FUN sign: int -> int

Negation (unary minus)

FUN -     : int -> int

Absolute value

FUN abs   : int -> int

Tests on integer numbers

Evenness and oddness

FUN even? odd?     : int -> bool

Tests for negative / zero / positive numbers

FUN neg? zero? pos? : int -> bool

Equality, inequality

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

Comparisons

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

Bracketings

multiplying operators have higher priority than adding operators

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

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

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

power has highest priority

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


next node: Nat,
prev node: Subsystem Numbers,
up to node: Subsystem Numbers