Integer numbers, bounded (from -1.073.741.824 to 1.073.741.823 )
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?
.
SORT int
It is not possible in OPAL to write down all numbers directly. The numbers used most often are introduced by the follwoing declarations:
FUN 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32: int
FUN 1 2 4 8 16 32 64 128 256 512 1024: int
FUN 1 10 100 1000 10000 100000 1000000: int
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
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
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
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