note description: "[ An arbitrary precision library for Rational numbers. Creation make, make_from_ints, make_from_string, make_from_real32, make_from_real64, Queries absolute: RATIONAL add (other: RATIONAL): RATIONAL as_real32: REAL_32 as_real64: REAL_64 divide alias "//" (other: RATIONAL): RATIONAL is_equal (other: RATIONAL): BOOLEAN is_greater alias ">" (other: RATIONAL): BOOLEAN is_greater_equal alias ">=" (other: RATIONAL): BOOLEAN is_less alias "<" (other: RATIONAL): BOOLEAN is_less_equal alias "<=" (other: RATIONAL): BOOLEAN is_valid_real_32: BOOLEAN is_valid_real_64: BOOLEAN max (other: [like Current] RATIONAL): RATIONAL min (other: [like Current] RATIONAL): RATIONAL minus alias "-" (other: RATIONAL): RATIONAL multiply (other: RATIONAL): RATIONAL negate: RATIONAL opposite alias "-": RATIONAL out: STRING_8 plus alias "+" (other: RATIONAL): RATIONAL power alias "^" (other: INTEGER): RATIONAL product alias "*" (other: RATIONAL): RATIONAL quotient alias "/" (other: RATIONAL): RATIONAL reciprocal: RATIONAL round_to (digits: INTEGER): STRING square: RATIONAL string_is_float (s: STRING): BOOLEAN string_is_fraction (s: STRING): BOOLEAN string_is_rational (s: STRING): BOOLEAN subtract (other: RATIONAL): RATIONAL Commands canonicalize ]" author: "JSO and AB" date: "$Date$" revision: "$Revision$" class interface RATIONAL create make, make_from_ints, make_from_string, make_from_real32, make_from_real64, default_create convert make_from_string ({STRING_8}), make_from_real32 ({REAL_32}), make_from_real64 ({REAL_64}), as_real32: {REAL_32}, as_real64: {REAL_64}, out: {STRING_8} feature -- Operations product alias "*" (other: like Current): like Current -- Return the result of multiplying Current by other -- Was declared in RATIONAL as synonym of multiply. multiply (other: like Current): like Current -- Return the result of multiplying Current by other -- Was declared in RATIONAL as synonym of product. plus alias "+" (other: like Current): like Current -- Return the result of adding Current to other -- Was declared in RATIONAL as synonym of add. add (other: like Current): like Current -- Return the result of adding Current to other -- Was declared in RATIONAL as synonym of plus. opposite alias "-": like Current -- Negate Current -- Was declared in RATIONAL as synonym of negate. negate: like Current -- Negate Current -- Was declared in RATIONAL as synonym of opposite. minus alias "-" (other: like Current): like Current -- Return the result of subtracting other from Current -- Was declared in RATIONAL as synonym of subtract. subtract (other: like Current): like Current -- Return the result of subtracting other from Current -- Was declared in RATIONAL as synonym of minus. reciprocal: like Current -- Return 1 / Current quotient alias "/" (other: like Current): like Current -- Return the result of dividing Curent by other -- Was declared in RATIONAL as synonym of divide. require denominator_non_zero: other /~ zero divide alias "//" (other: like Current): like Current -- Return the result of dividing Curent by other -- Was declared in RATIONAL as synonym of quotient. require denominator_non_zero: other /~ zero abs: like Current -- Absolute value of Current -- Was declared in RATIONAL as synonym of absolute. absolute: like Current -- Absolute value of Current -- Was declared in RATIONAL as synonym of abs. square: RATIONAL -- Return the value of Current * Current power alias "^" (other: INTEGER_32): RATIONAL -- Return the value of Current raised to the power other -- Was declared in RATIONAL as synonym of exp. exp (other: INTEGER_32): RATIONAL -- Return the value of Current raised to the power other -- Was declared in RATIONAL as synonym of power. feature -- rounding round_to (digits: INTEGER_32): STRING_8 -- Round Current to digits number of digits. Uses half-up rounding. feature -- Queries out: STRING_8 -- Return a string representation of Current debug_output: STRING_8 -- Debut output for Current is_canonical: BOOLEAN -- Is Current in canonical form? is_equal (other: like Current): BOOLEAN -- Is other value equal to current is_less alias "<" (other: like Current): BOOLEAN -- Is current object less than other? divisible (other: like Current): BOOLEAN -- May current object be divided by other? exponentiable (other: NUMERIC): BOOLEAN -- May current object be elevated to the power other? int_zero: BIG_INTEGER -- Returns an Integer with value 0 for creation one: like Current -- Neutral element for "*" and "/" zero: like Current -- Neutral element for "+" and "-" identity alias "+": like Current -- Unary plus string_is_fraction (s: STRING_8): BOOLEAN -- Does s represent a valid and well-defined fraction? -- It must contain at most one '/', which separates the numerator -- from the denominator (no whitespace allowed). Also, either -- the numerator or denominator must be non-zero. Further, if '/' -- is present, what comes before and after it must be valid INTs. -- If s doesn't contain a '/', a denominator of 1 is assumed. string_is_float (s: STRING_8): BOOLEAN -- Does s represent a valid and well-defined decimal number -- with potentially a floating point? This function was copied -- from {INT}.ensureValid, which came from mathmodels' VALUE. require non_void: s /= Void non_empty: not s.is_empty string_is_rational (s: STRING_8): BOOLEAN -- Does s represent a fraction or a decimal with a floating -- point? is_valid_real_64: BOOLEAN -- Is Current a valid REAL_64? is_valid_real_32: BOOLEAN -- Is Current a valid REAL_32? as_real64: REAL_64 -- Represent Current as a REAL_64 require is_valid_real_64 as_real32: REAL_32 -- Represent Current as a REAL_32 require is_valid_real_32 feature -- Internal queries get_p_q (s: STRING_8): TUPLE [a_p: like s; a_q: like s] -- Returns the numerator and denominator parsed from s. require string_is_rational (s) feature -- Commands canonicalize -- Canonicalize the current rational by dividing its numerator -- and denominator by their GCD. invariant well_defined: q /~ q.zero end -- class RATIONAL
Generated by ISE EiffelStudio