Libraries |
|
Integer | Source Code |
|
|
Operator Summary | |||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
void |
| ||||
void |
| ||||
void |
| ||||
void |
| ||||
void |
| ||||
integer |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
integer |
| ||||
string |
| ||||
string |
| ||||
string |
| ||||
integer |
| ||||
string |
|
Function Summary | |||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
boolean |
| ||||
integer |
| ||||
string |
| ||||
string |
| ||||
string |
| ||||
void |
| ||||
void |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
aType |
| ||||
aType |
|
Operator Detail |
+
const func integer: + (in integer: number)
-
Plus sign for integer numbers.
- Returns:
- its operand unchanged.
-
const func integer: - (in integer: number)
-
Minus sign, negate an integer number.
- Returns:
- the negated value of the number.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
!
const func integer: ! (in integer: number)
-
Compute the factorial of a number.
- Returns:
- the factorial of the number.
- Raises:
- NUMERIC_ERROR - The number is negative or the result does not fit into an integer.
+
const func integer: (in integer: summand1) + (in integer: summand2)
-
Add two integer numbers.
- Returns:
- the sum of the two numbers.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
-
const func integer: (in integer: minuend) - (in integer: subtrahend)
-
Compute the subtraction of two integer numbers.
- Returns:
- the difference of the two numbers.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
*
const func integer: (in integer: factor1) * (in integer: factor2)
-
Multiply two integer numbers.
- Returns:
- the product of the two numbers.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
div
const func integer: (in integer: dividend) div (in integer: divisor)
-
Integer division truncated towards zero. The remainder of this division is computed with rem. For the operations div and rem holds for all A:
(A div B) * B + A rem B = A when B <> 0 -A div B = -(A div B) when B <> 0 -A rem B = -(A rem B) when B <> 0 A rem B >= 0 and A rem B < abs(B) when B <> 0 and A >= 0 A rem B <= 0 and A rem B > -abs(B) when B <> 0 and A <= 0
- Returns:
- the quotient of the integer division.
- Raises:
- NUMERIC_ERROR - If a division by zero occurs.
- OVERFLOW_ERROR - If an integer overflow occurs.
rem
const func integer: (in integer: dividend) rem (in integer: divisor)
-
Compute the remainder of the integer division div. The remainder has the same sign as the dividend.
A rem B
is equivalent to
A - (A div B) * B
- Returns:
- the remainder of the integer division.
- Raises:
- NUMERIC_ERROR - If a division by zero occurs.
- OVERFLOW_ERROR - If an integer overflow occurs.
mdiv
const func integer: (in integer: dividend) mdiv (in integer: divisor)
-
Integer division truncated towards negative infinity. The modulo (remainder) of this division is computed with mod. Therefore this division is called modulo division (mdiv). For the operations mdiv and mod holds for all A:
(A mdiv B) * B + A mod B = A when B <> 0 -A mdiv B = A mdiv -B when B <> 0 -A mod -B = -(A mod B) when B <> 0 A mod B >= 0 and A mod B < B when B > 0 A mod B <= 0 and A mod B > B when B < 0
- Returns:
- the quotient of the integer division.
- Raises:
- NUMERIC_ERROR - If a division by zero occurs.
- OVERFLOW_ERROR - If an integer overflow occurs.
mod
const func integer: (in integer: dividend) mod (in integer: divisor)
-
Compute the modulo (remainder) of the integer division mdiv. The modulo has the same sign as the divisor.
A mod B
is equivalent to
A - (A mdiv B) * B
- Returns:
- the modulo of the integer division.
- Raises:
- NUMERIC_ERROR - If a division by zero occurs.
- OVERFLOW_ERROR - If an integer overflow occurs.
**
const func integer: (in integer: base) ** (in integer: exponent)
-
Compute the exponentiation of an integer base with an integer exponent.
A ** 0 returns 1 for every A, even for A = 0 1 ** B returns 1 for B >= 0 A ** B returns -(-A) ** B for A <= 0 and B >= 0 and odd(B) A ** B returns (-A) ** B for A <= 0 and B >= 0 and not odd(B)
- Returns:
- the result of the exponentiation.
- Raises:
- NUMERIC_ERROR - If the exponent is negative.
- OVERFLOW_ERROR - If an integer overflow occurs.
<<
const func integer: (in integer: number) << (in integer: lshift)
-
Shift an integer number left by lshift bits. A << B is equivalent to A * 2 ** B
- Returns:
- the left shifted number.
- Raises:
- OVERFLOW_ERROR - If the shift amount is negative or greater equal 64 or if an integer overflow occurs.
>>
const func integer: (in integer: number) >> (in integer: rshift)
-
Shift an integer number right by rshift bits. A >> B is equivalent to A mdiv 2 ** B
- Returns:
- the right shifted number.
- Raises:
- OVERFLOW_ERROR - If the shift amount is negative or greater equal 64.
+:=
const proc: (inout integer: number) +:= (in integer: delta)
-
Increment an integer variable by a delta.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
-:=
const proc: (inout integer: number) -:= (in integer: delta)
-
Decrement an integer variable by a delta.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
*:=
const proc: (inout integer: number) *:= (in integer: factor)
-
Multiply an integer number by a factor and assign the result back to number.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
<<:=
const proc: (inout integer: number) <<:= (in integer: lshift)
-
Shift a number left by lshift bits and assign the result back to number.
- Raises:
- OVERFLOW_ERROR - If the shift amount is negative or greater equal 64 or if an integer overflow occurs.
>>:=
const proc: (inout integer: number) >>:= (in integer: rshift)
-
Shift a number right by rshift bits and assign the result back to number.
- Raises:
- OVERFLOW_ERROR - If the shift amount is negative or greater equal 64.
!
const func integer: (in integer: n) ! (in integer: k)
-
Binomial coefficient
n ! k returns 0 for k < 0, n ! 0 returns 1, n ! 1 returns n, n ! k returns 0 for n >= 0 and k > n, n ! k returns !n div (!k * !(n - k)) for k >= 0 and k <= n, n ! k returns (-1) ** k * (n + k - 1 ! k) for n < 0 and k >= 0
- Returns:
- the binomial coefficient n over k
- Raises:
- OVERFLOW_ERROR - If the result would be less than integer.first or greater than integer.last.
=
const func boolean: (in integer: number1) = (in integer: number2)
-
Check if two integer numbers are equal.
- Returns:
- TRUE if the two numbers are equal, FALSE otherwise.
<>
const func boolean: (in integer: number1) <> (in integer: number2)
-
Check if two integer numbers are not equal.
- Returns:
- FALSE if the two numbers are equal, TRUE otherwise.
<
const func boolean: (in integer: number1) < (in integer: number2)
-
Check if number1 is less than number2.
- Returns:
- TRUE if number1 is less than number2, FALSE otherwise.
>
const func boolean: (in integer: number1) > (in integer: number2)
-
Check if number1 is greater than number2.
- Returns:
- TRUE if number1 is greater than number2, FALSE otherwise.
<=
const func boolean: (in integer: number1) <= (in integer: number2)
-
Check if number1 is less than or equal to number2.
- Returns:
- TRUE if number1 is less than or equal to number2, FALSE otherwise.
>=
const func boolean: (in integer: number1) >= (in integer: number2)
-
Check if number1 is greater than or equal to number2.
- Returns:
- TRUE if number1 is greater than or equal to number2, FALSE otherwise.
conv
const func integer: (attr integer) conv (in integer: number)
-
Convert to integer.
- Returns:
- the unchanged number.
radix
const func string: (in integer: number) radix (in integer: base)
-
Convert an integer number to a string using a radix. The conversion uses the numeral system with the given base. Digit values from 10 upward are encoded with lower case letters. E.g.: 10 is encoded with a, 11 with b, etc. For negative numbers a minus sign is prepended.
48879 radix 16 returns "beef" -48879 radix 16 returns "-beef"
- Parameters:
- number - Number to be converted to a string.
- base - Base of the numeral system used for the conversion.
- Returns:
- the string result of the conversion.
- Raises:
- RANGE_ERROR - If base < 2 or base > 36 holds.
- MEMORY_ERROR - Not enough memory to represent the result.
RADIX
const func string: (in integer: number) RADIX (in integer: base)
-
Convert an integer number to a string using a radix. The conversion uses the numeral system with the given base. Digit values from 10 upward are encoded with upper case letters. E.g.: 10 is encoded with A, 11 with B, etc. For negative numbers a minus sign is prepended.
48879 RADIX 16 returns "BEEF" -48879 RADIX 16 returns "-BEEF"
- Parameters:
- number - Number to be converted to a string.
- base - Base of the numeral system used for the conversion.
- Returns:
- the string result of the conversion.
- Raises:
- RANGE_ERROR - If base < 2 or base > 36 holds.
- MEMORY_ERROR - Not enough memory to represent the result.
lpad0
const func string: (in integer: number) lpad0 (in integer: length)
-
Convert integer to string and pad it with zeros at the left side. The number is converted to a string with decimal representation. For negative numbers a minus sign is prepended.
123 lpad0 5 returns "00123" -123 lpad0 5 returns "-0123" 123 lpad0 2 returns "123" -123 lpad0 2 returns "-123"
- Parameters:
- number - Number to be converted to a string.
- length - Minimum length of the result.
- Returns:
- number as decimal string left padded with zeroes.
- Raises:
- MEMORY_ERROR - Not enough memory to represent the result.
parse
const func integer: (attr integer) parse (in string: stri)
-
Convert a string to an integer number. The string must contain an integer literal consisting of an optional + or - sign, followed by a sequence of digits. Other characters as well as leading or trailing whitespace characters are not allowed. The sequence of digits is taken to be decimal.
integer parse "12345" returns 12345 integer parse "-12345" returns -12345 integer parse "+12345" returns 12345 integer parse " 12345" raises RANGE_ERROR integer parse "12345 " raises RANGE_ERROR integer parse "-" raises RANGE_ERROR integer parse "zero" raises RANGE_ERROR integer parse "9223372036854775807" returns 9223372036854775807 integer parse "9223372036854775808" raises RANGE_ERROR
- Returns:
- the integer result of the conversion.
- Raises:
- RANGE_ERROR - If the string is empty or it does not contain an integer literal or if the integer literal is too big or too small to be represented as integer value.
sci
const func string: (in integer: number) sci (in integer: precision)
-
Convert an integer number to a string in scientific notation. Scientific notation uses a decimal significand and a decimal exponent. The significand has an optional sign and exactly one digit before the decimal point. The fractional part of the significand is rounded to the specified number of digits (precision). Halfway cases are rounded away from zero. The fractional part is followed by the letter e and an exponent, which is always signed. The value zero is never written with a negative sign.
12345 sci 4 returns "1.2345e+4" 12345 sci 3 returns "1.235e+4" 12345 sci 2 returns "1.23e+4" 3141592 sci 0 returns "3e+6" 27182818 sci 0 returns "3e+7" 2**62 sci 6 returns "4.611686e+18" -1 sci 3 returns "-1.000e+0" -0 sci 2 returns "0.00e+0"
- Parameters:
- number - Number to be converted to a string.
- precision - Number of digits after the decimal point. If the precision is zero the decimal point is omitted.
- Returns:
- the string result of the conversion.
- Raises:
- RANGE_ERROR - If the precision is negative.
Function Detail |
compare
const func integer: compare (in integer: number1, in integer: number2)
-
Compare two integer numbers.
- Returns:
- -1, 0 or 1 if the first argument is considered to be respectively less than, equal to, or greater than the second.
hashCode
const func integer: hashCode (in integer: number)
-
Compute the hash value of an integer number.
- Returns:
- the hash value.
succ
const func integer: succ (in integer: number)
-
Successor of an integer number.
- Returns:
- number + 1
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
pred
const func integer: pred (in integer: number)
-
Predecessor of an integer number.
- Returns:
- number - 1
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
abs
const func integer: abs (in integer: number)
-
Compute the absolute value of an integer number.
- Returns:
- the absolute value.
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
sqrt
const func integer: sqrt (in integer: radicand)
-
Compute the integer square root of an integer radicand.
- Returns:
- the integer square root.
- Raises:
- NUMERIC_ERROR - If the radicand is negative.
log10
const func integer: log10 (in integer: number)
-
Compute the truncated base 10 logarithm of an integer number. The definition of log10 is extended by defining log10(0) = -1.
log10(10 ** A) returns A for A >= 0 log10(pred(10 ** A)) returns pred(A) for A >= 0 log10(10) returns 1 log10(1) returns 0 log10(0) returns -1
- Returns:
- the truncated base 10 logarithm.
- Raises:
- NUMERIC_ERROR - The number is negative.
log2
const func integer: log2 (in integer: number)
-
Compute the truncated base 2 logarithm of an integer number. The definition of log2 is extended by defining log2(0) = -1.
log2(2 ** A) returns A for A >= 0 log2(pred(2 ** A)) returns pred(A) for A >= 0 log2(2) returns 1 log2(1) returns 0 log2(0) returns -1
- Returns:
- the truncated base 2 logarithm.
- Raises:
- NUMERIC_ERROR - The number is negative.
odd
const func boolean: odd (in integer: number)
-
Determine if an integer number is odd.
- Returns:
- TRUE if the number is odd, FALSE otherwise.
str
const func string: str (in integer: number)
-
Convert an integer number to a string. The number is converted to a string with decimal representation. For negative numbers a minus sign is prepended.
- Parameters:
- number - Number to be converted to a string.
- Returns:
- the string result of the conversion.
- Raises:
- MEMORY_ERROR - Not enough memory to represent the result.
string
const func string: string (in integer: number)
-
Convert an integer number to a string. The number is converted to a string with decimal representation. For negative numbers a minus sign is prepended.
- Parameters:
- number - Number to be converted to a string.
- Returns:
- the string result of the conversion.
- Raises:
- MEMORY_ERROR - Not enough memory to represent the result.
literal
const func string: literal (in integer: number)
-
Convert an integer number to a string. The number is converted to a string with decimal representation. For negative numbers a minus sign is prepended.
- Parameters:
- number - Number to be converted to a string.
- Returns:
- the string result of the conversion.
- Raises:
- MEMORY_ERROR - Not enough memory to represent the result.
incr
const proc: incr (inout integer: number)
-
Increment an integer variable. Increments number by 1. This is equivalent to:
number := succ(number);
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
decr
const proc: decr (inout integer: number)
-
Decrement an integer variable. Decrements number by 1. This is equivalent to:
number := pred(number);
- Raises:
- OVERFLOW_ERROR - If an integer overflow occurs.
rand
const func integer: rand (in integer: low, in integer: high)
-
Compute pseudo-random number in the range [low, high]. The random values are uniform distributed.
- Returns:
- a random number such that low <= rand(low, high) and rand(low, high) <= high holds.
- Raises:
- RANGE_ERROR - The range is empty (low > high holds).
bitLength
const func integer: bitLength (in integer: number)
-
Number of bits in the minimum two's-complement representation. The high bits equivalent to the sign bit are not part of the minimum two's-complement representation.
bitLength(0) returns 0 bitLength(1) returns 1 bitLength(4) returns 3 bitLength(-1) returns 0 bitLength(-2) returns 1 bitLength(-4) returns 2
- Returns:
- the number of bits.
lowestSetBit
const func integer: lowestSetBit (in integer: number)
-
Number of lowest-order zero bits in the two's-complement representation. This is equal to the index of the lowest-order one bit (indices start with 0). If there are only zero bits (number is 0) the result is -1.
lowestSetBit(0) returns -1 lowestSetBit(1) returns 0 lowestSetBit(4) returns 2 lowestSetBit(-1) returns 0 lowestSetBit(-2) returns 1 lowestSetBit(-4) returns 2
- Returns:
- the number of lowest-order zero bits or -1 for lowestSetBit(0).
integer
const func integer: integer (in string: stri)
-
Convert a string to an integer number. The string must contain an integer literal consisting of an optional + or - sign, followed by a sequence of digits. Other characters as well as leading or trailing whitespace characters are not allowed. The sequence of digits is taken to be decimal.
integer("12345") returns 12345 integer("-12345") returns -12345 integer("+12345") returns 12345 integer(" 12345") raises RANGE_ERROR integer("12345 ") raises RANGE_ERROR integer("-") raises RANGE_ERROR integer("zero") raises RANGE_ERROR integer("9223372036854775807") returns 9223372036854775807 integer("9223372036854775808") raises RANGE_ERROR
- Returns:
- the integer result of the conversion.
- Raises:
- RANGE_ERROR - If the string is empty or it does not contain an integer literal or if the integer literal is too big or too small to be represented as integer value.
integer
const func integer: integer (in string: stri, in integer: base)
-
Convert a numeric string, with a specified radix, to an integer. The numeric string must contain the representation of an integer in the specified radix. It consists of an optional + or - sign, followed by a sequence of digits in the specified radix. Digit values from 10 upward can be encoded with upper or lower case letters. E.g.: 10 can be encoded with A or a, 11 with B or b, etc. Other characters as well as leading or trailing whitespace characters are not allowed.
integer("beef", 16) returns 48879 integer("-177", 8) returns -127 integer("10101010", 2) returns 170 integer("Cafe", 16) returns 51966
- Parameters:
- stri - Numeric string to be converted to an integer.
- base - Radix of the integer in the stri parameter.
- Returns:
- the integer result of the conversion.
- Raises:
- RANGE_ERROR - If base < 2 or base > 36 holds or the string is empty or it does not contain an integer literal with the specified base.
min
const func aType: min (in aType: value1, in aType: value2)
-
Determine the minimum of two values.
- Returns:
- the minimum of the two values.
max
const func aType: max (in aType: value1, in aType: value2)
-
Determine the maximum of two values.
- Returns:
- the maximum of the two values.
|
|