+
Point of view
All features
deferred class INTEGER_GENERAL
Summary
General integer abstraction to share common code for INTEGER_8, INTEGER_16, INTEGER_32 and INTEGER_64. (Keep in mind that, INTEGER is just a built_in short-hand for INTEGER_32.)
All implementations have a limited size (8, 16, 32 or 64 bits) and are supposed to use two's complement representation which is the most common one. Also keep in mind that INTEGER_8, INTEGER_16, INTEGER_32 and INTEGER_64 are expanded classes hence making polymorphism not possible (but keeping the very best execution speed).
If you need integers with bigger values, use NUMBER or MUTABLE_BIG_INTEGER.
See also NATURAL_8, NATURAL_16, NATURAL_32, NATURAL_64, NUMBER or MUTABLE_BIG_INTEGER.
Direct parents
Inherit list: INTEGRAL
Known children
Insert list: INTEGER_16, INTEGER_32, INTEGER_64, INTEGER_8
Overview
Features
{ANY}
{}
Conversions:
{ANY}
Bitwise Logical Operators:
{ANY}
  • bit_test (idx: INTEGER_8): BOOLEAN
    The value of the idx-ith bit (the right-most bit is at index 0).
  • bit_set (idx: INTEGER_8): INTEGER_GENERAL
    The value of the idx-ith bit (the right-most bit is at index 0).
  • bit_reset (idx: INTEGER_8): INTEGER_GENERAL
    The value of the idx-ith bit (the right-most bit is at index 0).
  • infix "|>>" (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions right (sign bit copied) bits falling off the end are lost.
  • bit_shift_right (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions right (sign bit copied) bits falling off the end are lost.
  • infix "|>>>" (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions right (sign bit not copied) bits falling off the end are lost.
  • bit_shift_right_unsigned (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions right (sign bit not copied) bits falling off the end are lost.
  • infix "|<<" (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions left bits falling off the end are lost.
  • bit_shift_left (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions left bits falling off the end are lost.
  • infix "#>>" (s: INTEGER_8): INTEGER_GENERAL
    Rotate by s positions right.
  • bit_rotate_right (s: INTEGER_8): INTEGER_GENERAL
    Rotate by s positions right.
  • infix "#<<" (s: INTEGER_8): INTEGER_GENERAL
    Rotate by s positions left.
  • bit_rotate_left (s: INTEGER_8): INTEGER_GENERAL
    Rotate by s positions left.
  • bit_rotate (s: INTEGER_8): INTEGER_GENERAL
    Rotate by s positions (positive s shifts right, negative left
  • prefix "~": INTEGER_GENERAL
    One's complement of Current.
  • bit_not: INTEGER_GENERAL
    One's complement of Current.
  • infix "&" (other: INTEGER_GENERAL): INTEGER_GENERAL
    Bitwise logical and of Current with other.
  • bit_and (other: INTEGER_GENERAL): INTEGER_GENERAL
    Bitwise logical and of Current with other.
  • infix "|" (other: INTEGER_GENERAL): INTEGER_GENERAL
    Bitwise logical inclusive or of Current with other.
  • bit_or (other: INTEGER_GENERAL): INTEGER_GENERAL
    Bitwise logical inclusive or of Current with other.
  • bit_xor (other: INTEGER_GENERAL): INTEGER_GENERAL
    Bitwise logical exclusive or of Current with other.
  • bit_shift (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions (positive s shifts right (sign bit copied), negative shifts left bits falling off the end are lost).
  • bit_shift_unsigned (s: INTEGER_8): INTEGER_GENERAL
    Shift by s positions (positive s shifts right (sign bit not copied), negative left bits falling off the end are lost).
Object Printing:
{ANY}
Miscellaneous:
{ANY}
Looping:
{ANY}
  • times (repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
    Repeats the procedure from 1 to Current.
  • loop_to (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
    Repeats the procedure from Current to bound.
  • loop_from (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
    Repeats the procedure from bound to Current.
  • loop_up_to (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
    Repeats the procedure from Current to a greater bound.
  • loop_down_to (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
    Repeats the procedure from Current to a lower bound.
Modular arithmetic (these wrap around on overflow)
{ANY}
  • infix "#+" (other: INTEGER_GENERAL): INTEGER_GENERAL
  • prefix "#-": INTEGER_GENERAL
  • infix "#-" (other: INTEGER_GENERAL): INTEGER_GENERAL
  • infix "#*" (other: INTEGER_GENERAL): INTEGER_GENERAL
  • infix "#//" (other: INTEGER_GENERAL): INTEGER_GENERAL
    Integer division of Current by other.
  • infix "#\\" (other: INTEGER_GENERAL): INTEGER_GENERAL
    Remainder of the integer division of Current by other.
Size query
{ANY}
{}
{ANY}
  • lcm (other: INTEGER_GENERAL): INTEGER_GENERAL
    Least Common Multiple of Current and other.
{ANY}
  • in_range (lower: INTEGER_GENERAL, upper: INTEGER_GENERAL): BOOLEAN
    Return True if Current is in range [lower..upper]
    See also min, max, compare.
  • compare (other: INTEGER_GENERAL): INTEGER_32
    If current object equal to other, 0 if smaller, -1; if greater, 1.
  • three_way_comparison (other: INTEGER_GENERAL): INTEGER_32
    If current object equal to other, 0 if smaller, -1; if greater, 1.
  • min (other: INTEGER_GENERAL): INTEGER_GENERAL
    Minimum of Current and other.
  • max (other: INTEGER_GENERAL): INTEGER_GENERAL
    Maximum of Current and other.
  • bounded_by (a_min: INTEGER_GENERAL, a_max: INTEGER_GENERAL): INTEGER_GENERAL
    A value that is equal to Current if it is between the limits set by a_min and a_max.
{ANY}
  • one: INTEGER_GENERAL
    Neutral element for "*" and "/".
  • zero: INTEGER_GENERAL
    Neutral element for "+" and "-".
{ANY}
Maximum:
{}
Minimum:
{}
Bits:
{}
infix "+" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Sum with other (commutative).
infix "-" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Result of subtracting other.
infix "*" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Product by other.
infix "/" (other: INTEGER_GENERAL): REAL_64
{ANY}
Division by other.
infix "//" (other: INTEGER_GENERAL): INTEGER_GENERAL
effective function
{ANY}
Quotient of the Euclidian division of Current by other.
infix "\\" (other: INTEGER_GENERAL): INTEGER_GENERAL
effective function
{ANY}
Remainder of the Euclidian division of Current by other.
infix "^" (exp: INTEGER_GENERAL): INTEGER_64
effective function
{ANY}
Integer power of Current by other
abs: INTEGER_GENERAL
effective function
{ANY}
Absolute value of Current.
infix "<" (other: INTEGER_GENERAL): BOOLEAN
{ANY}
Is Current strictly less than other?
infix "<=" (other: INTEGER_GENERAL): BOOLEAN
{ANY}
infix ">" (other: INTEGER_GENERAL): BOOLEAN
{ANY}
infix ">=" (other: INTEGER_GENERAL): BOOLEAN
{ANY}
prefix "+": INTEGER_GENERAL
effective function
{ANY}
Unary plus of Current.
prefix "-": INTEGER_GENERAL
{ANY}
Unary minus of Current.
is_odd: BOOLEAN
effective function
{ANY}
Is odd?
is_even: BOOLEAN
effective function
{ANY}
Is even?
is_prime: BOOLEAN
effective function
{ANY}
Is prime?
is_fibonacci: BOOLEAN
effective function
{ANY}
Is Fibonacci number?
sqrt: REAL_64
deferred function
{ANY}
Square root of Current.
log: REAL_64
deferred function
{ANY}
Natural Logarithm of Current.
log10: REAL_64
deferred function
{ANY}
Base-10 Logarithm of Current.
gcd (other: INTEGER_GENERAL): INTEGER_GENERAL
effective function
{ANY}
Greatest Common Divisor of Current and other.
is_perfect_square (other: INTEGER_GENERAL): BOOLEAN
effective function
{}
to_string: STRING
effective function
{ANY}
The decimal view of Current into a new allocated STRING.
to_unicode_string: UNICODE_STRING
effective function
{ANY}
The decimal view of Current into a new allocated UNICODE_STRING.
to_boolean: BOOLEAN
effective function
{ANY}
Return False for 0, otherwise True.
to_number: NUMBER
deferred function
{ANY}
Convert Current into a new allocated NUMBER.
append_in (buffer: STRING)
effective procedure
{ANY}
Append in the buffer the equivalent of to_string.
append_in_unicode (buffer: UNICODE_STRING)
effective procedure
{ANY}
Append in the buffer the equivalent of to_unicode_string.
to_string_format (s: INTEGER_32): STRING
effective function
{ANY}
Same as to_string but the result is on s character and the number is right aligned.
to_unicode_string_format (s: INTEGER_32): UNICODE_STRING
effective function
{ANY}
Same as to_unicode_string but the result is on s character and the number is right aligned.
append_in_format (buffer: STRING, s: INTEGER_32)
effective procedure
{ANY}
Append in the buffer the equivalent of to_string_format.
append_in_unicode_format (buffer: UNICODE_STRING, s: INTEGER_32)
effective procedure
{ANY}
Append in the buffer the equivalent of to_unicode_string_format.
digit: CHARACTER
effective function
{ANY}
Legacy synonym for decimal_digit.
is_decimal_digit: BOOLEAN
effective function
{ANY}
decimal_digit: CHARACTER
deferred function
{ANY}
Gives the corresponding CHARACTER for range 0..9.
is_hexadecimal_digit: BOOLEAN
effective function
{ANY}
hexadecimal_digit: CHARACTER
deferred function
{ANY}
Gives the corresponding CHARACTER for range 0..15.
to_character: CHARACTER
{ANY}
Return the corresponding ASCII character.
to_octal_in (buffer: STRING)
effective procedure
{ANY}
Append in the buffer the equivalent of to_octal.
to_octal: STRING
effective function
{ANY}
The octal view of Current into a new allocated STRING.
to_hexadecimal: STRING
effective function
{ANY}
The hexadecimal view of Current into a new allocated STRING.
to_hexadecimal_in (buffer: STRING)
effective procedure
{ANY}
Append in the buffer the equivalent of to_hexadecimal.
bit_test (idx: INTEGER_8): BOOLEAN
effective function
{ANY}
The value of the idx-ith bit (the right-most bit is at index 0).
bit_set (idx: INTEGER_8): INTEGER_GENERAL
effective function
{ANY}
The value of the idx-ith bit (the right-most bit is at index 0).
bit_reset (idx: INTEGER_8): INTEGER_GENERAL
effective function
{ANY}
The value of the idx-ith bit (the right-most bit is at index 0).
infix "|>>" (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Shift by s positions right (sign bit copied) bits falling off the end are lost.
bit_shift_right (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Shift by s positions right (sign bit copied) bits falling off the end are lost.
infix "|>>>" (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Shift by s positions right (sign bit not copied) bits falling off the end are lost.
bit_shift_right_unsigned (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Shift by s positions right (sign bit not copied) bits falling off the end are lost.
infix "|<<" (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Shift by s positions left bits falling off the end are lost.
bit_shift_left (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Shift by s positions left bits falling off the end are lost.
infix "#>>" (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Rotate by s positions right.
bit_rotate_right (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Rotate by s positions right.
infix "#<<" (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Rotate by s positions left.
bit_rotate_left (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Rotate by s positions left.
bit_rotate (s: INTEGER_8): INTEGER_GENERAL
{ANY}
Rotate by s positions (positive s shifts right, negative left
See also bit_rotate_right and bit_rotate_left.
prefix "~": INTEGER_GENERAL
{ANY}
One's complement of Current.
bit_not: INTEGER_GENERAL
{ANY}
One's complement of Current.
infix "&" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Bitwise logical and of Current with other.
bit_and (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Bitwise logical and of Current with other.
infix "|" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Bitwise logical inclusive or of Current with other.
bit_or (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Bitwise logical inclusive or of Current with other.
bit_xor (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Bitwise logical exclusive or of Current with other.
bit_shift (s: INTEGER_8): INTEGER_GENERAL
effective function
{ANY}
Shift by s positions (positive s shifts right (sign bit copied), negative shifts left bits falling off the end are lost).
bit_shift_unsigned (s: INTEGER_8): INTEGER_GENERAL
effective function
{ANY}
Shift by s positions (positive s shifts right (sign bit not copied), negative left bits falling off the end are lost).
out_in_tagged_out_memory
effective procedure
{ANY}
Append terse printable representation of current object in tagged_out_memory.
fill_tagged_out_memory
effective procedure
{ANY}
Append a viewable information in tagged_out_memory in order to affect the behavior of out, tagged_out, etc.
sign: INTEGER_8
effective function
{ANY}
Sign of Current (0 or -1 or 1).
divisible (other: INTEGER_GENERAL): BOOLEAN
effective function
{ANY}
May Current be divided by other ?
is_equal (other: INTEGER_GENERAL): BOOLEAN
effective function
{ANY}
Is other attached to an object considered equal to current object?
is_a_power_of_2: BOOLEAN
effective function
{ANY}
Is Current a power of 2?
times (repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
effective procedure
{ANY}
Repeats the procedure from 1 to Current.
loop_to (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
effective procedure
{ANY}
Repeats the procedure from Current to bound.
loop_from (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
effective procedure
{ANY}
Repeats the procedure from bound to Current.
loop_up_to (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
effective procedure
{ANY}
Repeats the procedure from Current to a greater bound.
loop_down_to (bound: INTEGER_GENERAL, repeat: PROCEDURE[TUPLE[TUPLE 1[INTEGER_GENERAL]]])
effective procedure
{ANY}
Repeats the procedure from Current to a lower bound.
infix "#+" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
prefix "#-": INTEGER_GENERAL
{ANY}
infix "#-" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
infix "#*" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
infix "#//" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Integer division of Current by other.
infix "#\\" (other: INTEGER_GENERAL): INTEGER_GENERAL
{ANY}
Remainder of the integer division of Current by other.
bit_count: INTEGER_8
deferred function
{ANY}
The number of bits used to store the value of Current
string_buffer: STRING
once function
{}
unicode_string_buffer: UNICODE_STRING
once function
{}
lcm (other: INTEGER_GENERAL): INTEGER_GENERAL
effective function
{ANY}
Least Common Multiple of Current and other.
in_range (lower: INTEGER_GENERAL, upper: INTEGER_GENERAL): BOOLEAN
effective function
{ANY}
Return True if Current is in range [lower..upper]
See also min, max, compare.
compare (other: INTEGER_GENERAL): INTEGER_32
effective function
{ANY}
If current object equal to other, 0 if smaller, -1; if greater, 1.
three_way_comparison (other: INTEGER_GENERAL): INTEGER_32
effective function
{ANY}
If current object equal to other, 0 if smaller, -1; if greater, 1.
min (other: INTEGER_GENERAL): INTEGER_GENERAL
effective function
{ANY}
Minimum of Current and other.
max (other: INTEGER_GENERAL): INTEGER_GENERAL
effective function
{ANY}
Maximum of Current and other.
bounded_by (a_min: INTEGER_GENERAL, a_max: INTEGER_GENERAL): INTEGER_GENERAL
effective function
{ANY}
A value that is equal to Current if it is between the limits set by a_min and a_max.
one: INTEGER_GENERAL
deferred function
{ANY}
Neutral element for "*" and "/".
zero: INTEGER_GENERAL
deferred function
{ANY}
Neutral element for "+" and "-".
hash_code: INTEGER_32
deferred function
{ANY}
The hash-code value of Current.
Maximum_character_code: INTEGER_16
{}
Largest supported code for CHARACTER values.
Maximum_integer_8: INTEGER_8
is 127
constant attribute
{}
Largest supported value of type INTEGER_8.
Maximum_integer_16: INTEGER_16
is 32767
constant attribute
{}
Largest supported value of type INTEGER_16.
Maximum_integer: INTEGER_32
is 2147483647
constant attribute
{}
Largest supported value of type INTEGER/INTEGER_32.
Maximum_integer_32: INTEGER_32
is 2147483647
constant attribute
{}
Largest supported value of type INTEGER/INTEGER_32.
Maximum_integer_64: INTEGER_64
is 9223372036854775807
constant attribute
{}
Largest supported value of type INTEGER_64.
Maximum_real_32: REAL_32
is {REAL_32 3.4028234663852885981170418348451692544e+38}
constant attribute
{}
Largest non-special (no NaNs nor infinity) supported value of type REAL_32.
Maximum_real: REAL_64
{}
Largest non-special (no NaNs nor infinity) supported value of type REAL.
Maximum_real_64: REAL_64
{}
Largest non-special (no NaNs nor infinity) supported value of type REAL.
Maximum_real_80: REAL_EXTENDED
{}
Largest supported value of type REAL_80.
Minimum_character_code: INTEGER_16
{}
Smallest supported code for CHARACTER values.
Minimum_integer_8: INTEGER_8
is -128
constant attribute
{}
Smallest supported value of type INTEGER_8.
Minimum_integer_16: INTEGER_16
is -32768
constant attribute
{}
Smallest supported value of type INTEGER_16.
Minimum_integer: INTEGER_32
is -2147483648
constant attribute
{}
Smallest supported value of type INTEGER/INTEGER_32.
Minimum_integer_32: INTEGER_32
is -2147483648
constant attribute
{}
Smallest supported value of type INTEGER/INTEGER_32.
Minimum_integer_64: INTEGER_64
is -9223372036854775808
constant attribute
{}
Smallest supported value of type INTEGER_64.
Minimum_real_32: REAL_32
is {REAL_32 -3.40282346638528859811704183484516925440e+38}
constant attribute
{}
Smallest non-special (no NaNs nor infinity) supported value of type REAL_32.
Minimum_real: REAL_64
{}
Smallest non-special (no NaNs nor infinity) supported value of type REAL.
Minimum_real_64: REAL_64
{}
Smallest non-special (no NaNs nor infinity) supported value of type REAL.
Minimum_real_80: REAL_64
{}
Smallest supported value of type REAL_80.
Boolean_bits: INTEGER_32
{}
Number of bits in a value of type BOOLEAN.
Character_bits: INTEGER_32
{}
Number of bits in a value of type CHARACTER.
Integer_bits: INTEGER_32
{}
Number of bits in a value of type INTEGER.
Real_bits: INTEGER_32
is 64
constant attribute
{}
Number of bits in a value of type REAL.
Pointer_bits: INTEGER_32
{}
Number of bits in a value of type POINTER.