note description: "DECIMAL numbers. Following the 'General Decimal Arithmetic Specification'." library: "Gobo Eiffel Decimal Arithmetic Library" copyright: "Copyright (c) 2004-2018, Paul G. Crismer and others" license: "MIT License" date: "$Date: 2019-02-07 22:54:15 +0000 (Thu, 07 Feb 2019) $" revision: "$Revision: 102807 $" class interface MA_DECIMAL create make_from_integer, make_from_string, make_from_string_ctx, make_copy, make_zero, make_one, make create {MA_DECIMAL} make_infinity, make_nan, make_snan, make_special create {MA_DECIMAL_TEXT_PARSER} make_from_parser feature -- Access sign: INTEGER_32 -- Sign: positive = 1; negative = -1 ensure definition1: Result = -1 implies is_negative definition2: Result = 1 implies is_positive exponent: INTEGER_32 -- Current exponent hash_code: INTEGER_32 -- Hash code value feature -- Constants one: like Current -- Neutral element for "*" and "/" ensure then instance_free: class one_is_one: Result.is_one one_is_positive: not Result.is_negative Minus_one: MA_DECIMAL -- Minus one ensure instance_free: class minus_one_not_void: Result /= Void is_minus_one: Result.is_one and then Result.is_negative zero: like Current -- Neutral element for "+" and "-" ensure then instance_free: class is_zero: Result.is_zero Negative_zero: MA_DECIMAL -- Negative zero ensure instance_free: class negative_zero_not_void: Result /= Void is_zero: Result.is_zero is_negative: Result.is_negative Nan: MA_DECIMAL -- Not a Number ensure instance_free: class nan_not_void: Result /= Void is_nan: Result.is_nan Snan: MA_DECIMAL -- Signaling Not a Number ensure instance_free: class snan_not_void: Result /= Void is_snan: Result.is_signaling_nan Infinity: MA_DECIMAL -- Infinity ensure instance_free: class infinity_not_void: Result /= Void is_infinity: Result.is_infinity is_positive: Result.is_positive Negative_infinity: MA_DECIMAL -- Negative infinity ensure instance_free: class negative_infinity_not_void: Result /= Void is_infinity: Result.is_infinity is_negative: Result.is_negative feature -- Status report is_integer: BOOLEAN -- Is this an integer? -- (i.e no fractional part other than all zeroes) is_double: BOOLEAN -- Is this a double? divisible (other: like Current): BOOLEAN -- May current object be divided by other? ensure then definition: Result = not other.is_zero exponentiable (other: NUMERIC): BOOLEAN -- May current object be elevated to the power other? is_negative: BOOLEAN -- Is the number negative? is_positive: BOOLEAN -- Is the number positive? ensure definition: Result = not is_negative is_nan: BOOLEAN -- Is this "Not a Number" (NaN)? ensure definition: Result = (is_signaling_nan or is_quiet_nan) is_special: BOOLEAN -- Is this a special value? ensure definition: Result = (is_nan or else is_infinity) is_signaling_nan: BOOLEAN -- Is this a "Signaling NaN"? is_quiet_nan: BOOLEAN -- Is this a "Quiet NaN"? is_infinity: BOOLEAN -- Is this an Infinity? is_zero: BOOLEAN -- Is this a Zero value? ensure definition: Result = (not is_special and then coefficient.is_zero) is_one: BOOLEAN -- Is this a One ? ensure definition: Result = (not is_special and then exponent = 0 and then coefficient.is_one) feature -- Basic operations product alias "*" (other: like Current): like Current -- Product by other ensure then product_not_void: Result /= Void identity alias "+": like Current -- Unary plus ensure then unary_plus_not_void: Result /= Void binary_plus alias "+" (other: like Current): like Current -- Sum with other (commutative) ensure then sum_not_void: Result /= Void opposite alias "-": like Current -- Unary minus ensure then unary_minus_not_void: Result /= Void binary_minus alias "-" (other: like Current): like Current -- Result of subtracting other ensure then subtract_not_void: Result /= Void quotient alias "/" (other: like Current): like Current -- Division by other ensure then division_not_void: Result /= Void integer_remainder alias "\\" (other: like Current): like Current -- Remainder of integer division ensure remainder_not_void: Result /= Void integer_quotient alias "//" (other: like Current): like Current -- Integer division ensure integer_division_not_void: Result /= Void power alias "^" (other: NUMERIC): MA_DECIMAL -- Current decimal to the power other is_less alias "<" (other: like Current): BOOLEAN -- Is current decimal less than other? feature -- Measurement count: INTEGER_32 -- Count of significant digits ensure zero_when_special: is_special implies Result = 0 feature -- Comparison is_equal (other: like Current): BOOLEAN -- Are Current and other considered equal? feature -- Conversion out: STRING_8 -- Printable representation to_double: REAL_64 -- Current as a DOUBLE require is_double: is_double to_integer: INTEGER_32 -- Current as an INTEGER require is_integer: is_integer large_enough: Current >= Decimal.Minimum_integer small_enough: Current <= Decimal.Maximum_integer to_integer_ctx (ctx: MA_DECIMAL_CONTEXT): INTEGER_32 -- Current as an INTEGER wrt ctx require is_integer: is_integer large_enough: Current >= Decimal.Minimum_integer small_enough: Current <= Decimal.Maximum_integer to_engineering_string: STRING_8 -- Current as a string in engineering notation format ensure to_string_not_void: Result /= Void to_scientific_string: STRING_8 -- Current as a string in scientific notation format ensure to_string_not_void: Result /= Void feature -- Duplication copy (other: like Current) -- Copy other to current decimal. feature -- Basic operations add (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Add other with respect to the ctx context require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure add_not_void: Result /= Void subtract (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Subtract other with respect to the ctx context require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure subtract_not_void: Result /= Void multiply (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Multiply other with respect to ctx require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure multiply_not_void: Result /= Void divide (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Divide Current by other whith respect to ctx require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure divide_not_void: Result /= Void divide_integer (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Integer division of Current by other whith respect to ctx require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure divide_integer_not_void: Result /= Void remainder (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Remainder of integer division of Current by other whith respect to ctx require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure remainder_not_void: Result /= Void rescale (new_exponent: INTEGER_32; ctx: MA_DECIMAL_CONTEXT): like Current -- Decimal from Current rescaled to new_exponent require ctx_not_void: ctx /= Void ensure rescale_not_void: Result /= Void rescale_decimal (new_exponent: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Rescale using decimal new_exponent require new_exponent_not_void: new_exponent /= Void ctx_not_void: ctx /= Void ensure rescale_decimal_not_void: Result /= Void round_to_integer (ctx: MA_DECIMAL_CONTEXT): like Current -- Round to an integer with exponent 0 require ctx_not_void: ctx /= Void ensure round_to_integer_not_void: Result /= Void definition: not Result.is_special implies Result.exponent = 0 plus (ctx: MA_DECIMAL_CONTEXT): like Current -- Prefix "+" with respect to the ctx context require ctx_not_void: ctx /= Void ensure plus_not_void: Result /= Void normalize: like Current -- Normalized version of current decimal ensure normalize_not_void: Result /= Void minus (ctx: MA_DECIMAL_CONTEXT): like Current -- Prefix "-" with respect to the ctx context require ctx_not_void: ctx /= Void ensure minus_not_void: Result /= Void abs: like Current -- Absolute value of Current ensure abs_not_void: Result /= Void abs_ctx (ctx: MA_DECIMAL_CONTEXT): like Current -- Absolute value of Current relative to ctx require ctx_not_void: ctx /= Void ensure abs_ctx_not_void: Result /= Void definition: Result.sign >= 0 max_ctx (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Max between Current and other relative to ctx require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure max_ctx_not_void: Result /= Void min_ctx (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Min between Current and other relative to ctx require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure min_ctx_not_void: Result /= Void compare (other: like Current; ctx: MA_DECIMAL_CONTEXT): like Current -- Compare value of Current and other; -- Result = 0 if Current = other, -- Result = -1 if Current < other, -- Result = +1 if Current > other. require other_not_void: other /= Void ctx_not_void: ctx /= Void ensure compare_not_void: Result /= Void invariant special_values: special >= Special_none and then special <= Special_quiet_nan coefficient_not_void: coefficient /= Void special_share_coefficient: is_special implies coefficient = Special_coefficient special_has_exponent_zero: is_special implies exponent = 0 special_coefficient_is_zero: Special_coefficient.is_zero end -- class MA_DECIMAL
Generated by ISE EiffelStudio