note description: "[ An arbitrary precision library for integer numbers. Creation make_from_string, make_from_integer64, make_from_integer32, Queries absolute: BIG_INTEGER as_integer32: INTEGER as_integer64: INTEGER divide (other: BIG_INTEGER): BIG_INTEGER gcd (other: BIG_INTEGER): BIG_INTEGER is_equal (other: BIG_INTEGER): BOOLEAN is_greater alias ">" (other: [like Current] BIG_INTEGER): BOOLEAN is_greater_equal alias ">=" (other: [like Current] BIG_INTEGER): BOOLEAN is_less alias "<" (other: BIG_INTEGER): BOOLEAN is_less_equal alias "<=" (other: [like Current] BIG_INTEGER): BOOLEAN max (other: [like Current] BIG_INTEGER): [like Current] BIG_INTEGER min (other: [like Current] BIG_INTEGER): [like Current] BIG_INTEGER minus alias "-" (other: BIG_INTEGER): BIG_INTEGER opposite alias "-": BIG_INTEGER out: STRING plus alias "+" (other: BIG_INTEGER): BIG_INTEGER power alias "^" (other: INTEGER): BIG_INTEGER product alias "*" (other: BIG_INTEGER): BIG_INTEGER quotient alias "//" (other: BIG_INTEGER): BIG_INTEGER remainder alias "\\" (other: BIG_INTEGER): BIG_INTEGER square: BIG_INTEGER ]" author: "JSO" date: "$17 July, 2018$" revision: "$0.91$" class interface BIG_INTEGER create make_from_string, make_from_integer64, make_from_integer32, default_create convert make_from_string ({STRING_8}), make_from_integer64 ({INTEGER_64}), make_from_integer32 ({INTEGER_32}), as_integer64: {INTEGER_64}, as_integer32: {INTEGER_32}, out: {STRING_8} feature -- comparison is_equal (other: BIG_INTEGER): BOOLEAN -- Is other equal to Current? is_less alias "<" (other: BIG_INTEGER): BOOLEAN -- Is Current less than other? feature -- operations plus alias "+" (other: BIG_INTEGER): BIG_INTEGER -- Returns the result of adding other to Current minus alias "-" (other: BIG_INTEGER): BIG_INTEGER -- Returns the result of subtracting other from Current -- Was declared in BIG_INTEGER as synonym of subtract. subtract (other: BIG_INTEGER): BIG_INTEGER -- Returns the result of subtracting other from Current -- Was declared in BIG_INTEGER as synonym of minus. product alias "*" (other: BIG_INTEGER): BIG_INTEGER -- Returns the result of multiplying Current with other quotient alias "//" (other: BIG_INTEGER): BIG_INTEGER -- Returns the result of dividing Current from other -- Was declared in BIG_INTEGER as synonym of divide. require denominator_non_zero: other /~ zero divide (other: BIG_INTEGER): BIG_INTEGER -- Returns the result of dividing Current from other -- Was declared in BIG_INTEGER as synonym of quotient. require denominator_non_zero: other /~ zero square: BIG_INTEGER -- Returns the result of Current * Current power alias "^" (other: INTEGER_32): BIG_INTEGER -- Returns the result of raising Current to the power other -- Was declared in BIG_INTEGER as synonym of exp. require power_non_zero: other >= 0 exp (other: INTEGER_32): BIG_INTEGER -- Returns the result of raising Current to the power other -- Was declared in BIG_INTEGER as synonym of power. require power_non_zero: other >= 0 remainder alias "\\" (other: BIG_INTEGER): BIG_INTEGER -- Return the result of Current mod other (Consistent with WolframAlpha's mod) require non_zero: other /~ zero gcd (other: BIG_INTEGER): BIG_INTEGER -- Return the positive greatest common divisor of Current and other require both_not_zero: Current /~ zero or other /~ zero negate -- negates the number absolute: BIG_INTEGER -- Returns the absolute value of Current ensure Result >= Result.zero feature -- conversion as_integer64: INTEGER_64 -- represent as a integer 64 require valid_int64: out.is_integer_64 as_integer32: INTEGER_32 -- represent as a integer 32 require valid_int32: out.is_integer_32 feature -- queries out: STRING_8 -- New string containing terse printable representation -- of current object opposite alias "-": BIG_INTEGER -- unary minus identity alias "+": BIG_INTEGER -- unary plus zero: BIG_INTEGER -- neutral element for "+" and "-" one: BIG_INTEGER -- neutral element for "*" and "/" divisible (other: BIG_INTEGER): BOOLEAN -- may current object be divided by other? is_natural: BOOLEAN -- Is Current a natural number? is_natural1: BOOLEAN -- Is `Current a Natural1 number? is_integer: BOOLEAN -- Is string representation item an int? feature -- is_string_int is_string_int (s: STRING_8): BOOLEAN -- Is the given string a representation of big integer? require non_empty: not s.is_empty invariant Default_precision = 0 is_integer note copyright: "Copyright (c) SEL, York University" license: "MIT" todo: "[ integer division \\ is veru ineficient. Fpr js algorithm see: www.javascripter.net/math/calculators/100digitbigintcalculator.htm and {TEST_INT_JSO}t51. To generate large random numbers: python3 import random random.getrandbits(128) -- 128 bits ]" end -- class BIG_INTEGER
Generated by ISE EiffelStudio