Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Wildcard Window Wrinum X.509 Xmldom Xml_ent Zip
Libraries
Integer Source Code
 previous   up   next 

Operator Summary
integer
(attr integer) . first
Minimum value of integer (-9223372036854775808).
integer
(attr integer) . last
Maximum value of integer (9223372036854775807).
integer
+ (in integer: number)
Plus sign for integer numbers.
integer
- (in integer: number)
Minus sign, negate an integer number.
integer
! (in integer: number)
Compute the factorial of a number.
integer
(in integer: summand1) + (in integer: summand2)
Add two integer numbers.
integer
(in integer: minuend) - (in integer: subtrahend)
Compute the subtraction of two integer numbers.
integer
(in integer: factor1) * (in integer: factor2)
Multiply two integer numbers.
integer
(in integer: dividend) div (in integer: divisor)
Integer division truncated towards zero.
integer
(in integer: dividend) rem (in integer: divisor)
Compute the remainder of the integer division div.
integer
(in integer: dividend) mdiv (in integer: divisor)
Integer division truncated towards negative infinity.
integer
(in integer: dividend) mod (in integer: divisor)
Compute the modulo (remainder) of the integer division mdiv.
integer
(in integer: base) ** (in integer: exponent)
Compute the exponentiation of a integer base with an integer exponent.
integer
(in integer: number) << (in integer: lshift)
Shift an integer number left by lshift bits.
integer
(in integer: number) >> (in integer: rshift)
Shift an integer number right by rshift bits.
void
(inout integer: number) +:= (in integer: delta)
Increment an integer variable by a delta.
void
(inout integer: number) -:= (in integer: delta)
Decrement an integer variable by a delta.
void
(inout integer: number) *:= (in integer: factor)
Multiply an integer number by a factor and assign the result back to number.
void
(inout integer: number) <<:= (in integer: lshift)
Shift a number left by lshift bits and assign the result back to number.
void
(inout integer: number) >>:= (in integer: rshift)
Shift a number right by rshift bits and assign the result back to number.
integer
(in integer: n) ! (in integer: k)
Binomial coefficient
boolean
(in integer: number1) = (in integer: number2)
Check if two integer numbers are equal.
boolean
(in integer: number1) <> (in integer: number2)
Check if two integer numbers are not equal.
boolean
(in integer: number1) < (in integer: number2)
Check if number1 is less than number2.
boolean
(in integer: number1) > (in integer: number2)
Check if number1 is greater than number2.
boolean
(in integer: number1) <= (in integer: number2)
Check if number1 is less than or equal to number2.
boolean
(in integer: number1) >= (in integer: number2)
Check if number1 is greater than or equal to number2.
integer
(attr integer) conv (in integer: number)
Convert to integer.
string
(in integer: number) radix (in integer: base)
Convert an integer number to a string using a radix.
string
(in integer: number) RADIX (in integer: base)
Convert an integer number to a string using a radix.
string
(in integer: number) lpad0 (in integer: length)
Convert integer to string and pad it with zeros at the left side.
integer
(attr integer) parse (in string: stri)
Convert a string to an integer number.
string
(in integer: number) sci (in integer: precision)
Convert an integer number to a string in scientific notation.

Function Summary
integer
compare (in integer: number1, in integer: number2)
Compare two integer numbers.
integer
hashCode (in integer: number)
Compute the hash value of an integer number.
integer
succ (in integer: number)
Successor of an integer number.
integer
pred (in integer: number)
Predecessor of an integer number.
integer
abs (in integer: number)
Compute the absolute value of an integer number.
integer
sqrt (in integer: number)
Compute the truncated square root of an integer number.
integer
log10 (in integer: number)
Compute the truncated base 10 logarithm of an integer number.
integer
log2 (in integer: number)
Compute the truncated base 2 logarithm of an integer number.
boolean
odd (in integer: number)
Determine if a integer number is odd.
integer
ord (in integer: number)
Convert to integer.
string
str (in integer: number)
Convert an integer number to a string.
string
literal (in integer: number)
Convert an integer number to a string.
void
incr (inout integer: number)
Increment an integer variable.
void
decr (inout integer: number)
Decrement an integer variable.
integer
rand (in integer: low, in integer: high)
Compute pseudo-random number in the range [low, high].
integer
bitLength (in integer: number)
Number of bits in the minimal two's-complement representation.
integer
lowestSetBit (in integer: number)
Index of the lowest-order one bit.
integer
integer (in string: stri)
Convert a string to an integer number.
integer
integer (in string: stri, in integer: base)
Convert a numeric string, with a specified radix, to an integer.
integer
min (in integer: value1, in integer: value2)
Determine the minimum of two integer numbers.
integer
max (in integer: value1, in integer: value2)
Determine the maximum of two integer numbers.

Operator Detail

. first

const integer: (attr integer) . first

Minimum value of integer (-9223372036854775808).


. last

const integer: (attr integer) . last

Maximum value of integer (9223372036854775807).


+

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 - When 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 - When 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 - When 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 - When 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 - When a division by zero occurs.
OVERFLOW_ERROR - When 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 - When a division by zero occurs.
OVERFLOW_ERROR - When 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 - When a division by zero occurs.
OVERFLOW_ERROR - When 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 - When a division by zero occurs.
OVERFLOW_ERROR - When an integer overflow occurs.

**

const func integer: (in integer: base) ** (in integer: exponent)

Compute the exponentiation of a 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 exponentation.
Raises:
NUMERIC_ERROR - When the exponent is negative.
OVERFLOW_ERROR - When 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 - When the shift amount is negative or greater equal 64 or when 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 - When 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 - When an integer overflow occurs.

-:=

const proc: (inout integer: number) -:= (in integer: delta)

Decrement an integer variable by a delta.

Raises:
OVERFLOW_ERROR - When 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 - When 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 - When the shift amount is negative or greater equal 64 or when 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 - When the shift amount is negative or greater equal 64.

!

const func integer: (in integer: n) ! (in integer: k)

Binomial coefficient

n ! k  returns  !n div (!k * !(n - k))
Returns:
n over k
Raises:
OVERFLOW_ERROR - When 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 both 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 - When 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 - When 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.

Returns:
the integer result of the conversion.
Raises:
RANGE_ERROR - When the string is empty or it does not contain an integer literal or when 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. When the precision is zero the decimal point is omitted.
Returns:
the string result of the conversion.
Raises:
RANGE_ERROR - When 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 - When an integer overflow occurs.

pred

const func integer: pred (in integer: number)

Predecessor of an integer number.

Returns:
number - 1
Raises:
OVERFLOW_ERROR - When 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 - When an integer overflow occurs.

sqrt

const func integer: sqrt (in integer: number)

Compute the truncated square root of an integer number.

Returns:
the integer square root.
Raises:
NUMERIC_ERROR - When number 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 a integer number is odd.

Returns:
TRUE if the number is odd, FALSE otherwise.

ord

const func integer: ord (in integer: number)

Convert to integer.

Returns:
the unchanged number.

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.

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 - When 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 - When 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 minimal two's-complement representation. The high bits equivalent to the sign bit are not part of the minimal two's-complement representation.

Returns:
the number of bits.

lowestSetBit

const func integer: lowestSetBit (in integer: number)

Index of the lowest-order one bit. For A <> 0 this is equal to the number of lowest-order zero bits.

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.

Returns:
the integer result of the conversion.
Raises:
RANGE_ERROR - When the string is empty or it does not contain an integer literal or when 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 - When 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 integer: min (in integer: value1, in integer: value2)

Determine the minimum of two integer numbers.

Returns:
the minimum of the two numbers.

max

const func integer: max (in integer: value1, in integer: value2)

Determine the maximum of two integer numbers.

Returns:
the maximum of the two numbers.


 previous   up   next