Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:
indexing description: "Integer values" status: "See notice at end of class" date: "$Date: 2001-11-16 20:32:23 +0000 (Fri, 16 Nov 2001) $" revision: "$Revision: 51435 $" expanded class INTEGER feature -- Access ascii_char: CHARACTER is -- Returns corresponding ASCII character to item value. -- (from INTEGER_REF) do Result := c_ascii_char (item) end hash_code: INTEGER is -- Hash code value -- (from INTEGER_REF) do if item >= 0 then Result := item else Result := - (item + 1) end ensure -- from HASHABLE good_hash_value: Result >= 0 end item: INTEGER -- Integer value -- (from INTEGER_REF) one: like Current is -- Neutral element for "*" and "/" -- (from INTEGER_REF) do create Result Result.set_item (1) ensure -- from NUMERIC result_exists: Result /= void end sign: INTEGER is -- Sign value (0, -1 or 1) -- (from INTEGER_REF) do if item > 0 then Result := 1 elseif item < 0 then Result := - 1 end ensure -- from INTEGER_REF three_way: Result = three_way_comparison (zero) end zero: like Current is -- Neutral element for "+" and "-" -- (from INTEGER_REF) do create Result Result.set_item (0) ensure -- from NUMERIC result_exists: Result /= void end feature -- Comparison is_equal (other: like Current): BOOLEAN is -- Is other attached to an object of the same type -- as current object and identical to it? -- (from INTEGER_REF) require -- from ANY other_not_void: other /= void do Result := other.item = item ensure -- from ANY symmetric: Result implies other.is_equal (Current) consistent: standard_is_equal (other) implies Result ensure then -- from COMPARABLE trichotomy: Result = (not (Current < other) and not (other < Current)) end max (other: like Current): like Current is -- The greater of current object and other -- (from COMPARABLE) require -- from COMPARABLE other_exists: other /= void do if Current >= other then Result := Current else Result := other end ensure -- from COMPARABLE current_if_not_smaller: Current >= other implies Result = Current other_if_smaller: Current < other implies Result = other end min (other: like Current): like Current is -- The smaller of current object and other -- (from COMPARABLE) require -- from COMPARABLE other_exists: other /= void do if Current <= other then Result := Current else Result := other end ensure -- from COMPARABLE current_if_not_greater: Current <= other implies Result = Current other_if_greater: Current > other implies Result = other end three_way_comparison (other: INTEGER_REF): INTEGER is -- If current object equal to other, 0 -- if smaller, -1; if greater, 1 -- (from INTEGER_REF) require -- from COMPARABLE other_exists: other /= void do if item < other.item then Result := - 1 elseif other.item < item then Result := 1 end ensure -- from COMPARABLE equal_zero: (Result = 0) = is_equal (other) smaller_negative: (Result = - 1) = (Current < other) greater_positive: (Result = 1) = (Current > other) end infix "<" (other: like Current): BOOLEAN is -- Is current integer less than other? -- (from INTEGER_REF) require -- from PART_COMPARABLE other_exists: other /= void do Result := item < other.item ensure then -- from COMPARABLE asymmetric: Result implies not (other < Current) end infix "<=" (other: like Current): BOOLEAN is -- Is current object less than or equal to other? -- (from COMPARABLE) require -- from PART_COMPARABLE other_exists: other /= void do Result := not (other < Current) ensure then -- from COMPARABLE definition: Result = ((Current < other) or is_equal (other)) end infix ">" (other: like Current): BOOLEAN is -- Is current object greater than other? -- (from COMPARABLE) require -- from PART_COMPARABLE other_exists: other /= void do Result := other < Current ensure then -- from COMPARABLE definition: Result = (other < Current) end infix ">=" (other: like Current): BOOLEAN is -- Is current object greater than or equal to other? -- (from COMPARABLE) require -- from PART_COMPARABLE other_exists: other /= void do Result := not (Current < other) ensure then -- from COMPARABLE definition: Result = (other <= Current) end feature -- Status report divisible (other: INTEGER_REF): BOOLEAN is -- May current object be divided by other? -- (from INTEGER_REF) require -- from NUMERIC other_exists: other /= void do Result := other.item /= 0 ensure then -- from INTEGER_REF value: Result = (other.item /= 0) end exponentiable (other: NUMERIC): BOOLEAN is -- May current object be elevated to the power other? -- (from INTEGER_REF) require -- from NUMERIC other_exists: other /= void local integer_value: INTEGER_REF double_value: DOUBLE_REF real_value: REAL_REF do integer_value ?= other real_value ?= other double_value ?= other if integer_value /= void then Result := integer_value.item >= 0 or item /= 0 elseif real_value /= void then Result := real_value.item >= 0.0 or item /= 0 elseif double_value /= void then Result := double_value.item >= 0.0 or item /= 0 end ensure then -- from INTEGER_REF safe_values: ((other.conforms_to (0) and item /= 0) or (other.conforms_to (0.0) and item > 0)) implies Result end is_hashable: BOOLEAN is -- May current object be hashed? -- (True if it is not its type's default.) -- (from INTEGER_REF) do Result := item /= 0 ensure -- from HASHABLE ok_if_not_default: Result implies (Current /= default) end feature -- Element change set_item (i: INTEGER) is -- Make i the item value. -- (from INTEGER_REF) do item := i end feature -- Conversion to_boolean: BOOLEAN is -- True if not zero. -- (from INTEGER_REF) do Result := item /= 0 end to_integer_16: INTEGER_16 is -- Convert item into an INTEGER_16 value. -- (from INTEGER_REF) require -- from INTEGER_REF not_too_small: item >= - 32768 not_too_big: item <= 32767 do Result := item.to_integer_16 end to_integer_64: INTEGER_64 is -- Convert item into an INTEGER_64 value. -- (from INTEGER_REF) do Result := item.to_integer_64 end to_integer_8: INTEGER_8 is -- Convert item into an INTEGER_8 value. -- (from INTEGER_REF) require -- from INTEGER_REF not_too_small: item >= - 128 not_too_big: item <= 127 do Result := item.to_integer_8 end feature -- Basic operations abs: INTEGER is -- Absolute value -- (from INTEGER_REF) do Result := abs_ref.item ensure -- from INTEGER_REF non_negative: Result >= 0 same_absolute_value: (Result = item) or (Result = - item) end infix "*" (other: like Current): like Current is -- Product by other -- (from INTEGER_REF) require -- from NUMERIC other_exists: other /= void do create Result Result.set_item (item * other.item) ensure -- from NUMERIC result_exists: Result /= void end prefix "+": like Current is -- Unary plus -- (from INTEGER_REF) do create Result Result.set_item (+ item) ensure -- from NUMERIC result_exists: Result /= void end infix "+" (other: like Current): like Current is -- Sum with other -- (from INTEGER_REF) require -- from NUMERIC other_exists: other /= void do create Result Result.set_item (item + other.item) ensure -- from NUMERIC result_exists: Result /= void commutative: equal (Result, other + Current) end prefix "-": like Current is -- Unary minus -- (from INTEGER_REF) do create Result Result.set_item (- item) ensure -- from NUMERIC result_exists: Result /= void end infix "-" (other: like Current): like Current is -- Result of subtracting other -- (from INTEGER_REF) require -- from NUMERIC other_exists: other /= void do create Result Result.set_item (item - other.item) ensure -- from NUMERIC result_exists: Result /= void end infix "/" (other: like Current): DOUBLE is -- Division by other -- (from INTEGER_REF) require -- from INTEGER_REF other_exists: other /= void good_divisor: divisible (other) do Result := item / other.item end infix "//" (other: like Current): like Current is -- Integer division of Current by other -- (from INTEGER_REF) require -- from NUMERIC other_exists: other /= void good_divisor: divisible (other) do create Result Result.set_item (item // other.item) ensure -- from NUMERIC result_exists: Result /= void end infix "\\" (other: like Current): like Current is -- Remainder of the integer division of Current by other -- (from INTEGER_REF) require -- from INTEGER_REF other_exists: other /= void good_divisor: divisible (other) do create Result Result.set_item (item \\ other.item) ensure -- from INTEGER_REF result_exists: Result /= void end infix "^" (other: NUMERIC): DOUBLE is -- Integer power of Current by other -- (from INTEGER_REF) local integer_value: INTEGER_REF real_value: REAL_REF double_value: DOUBLE_REF do integer_value ?= other real_value ?= other double_value ?= other if integer_value /= void then Result := item ^ integer_value.item elseif real_value /= void then Result := item ^ real_value.item elseif double_value /= void then Result := item ^ double_value.item end end infix "|..|" (other: INTEGER): INTEGER_INTERVAL is -- Interval from current element to other -- (empty if other less than current integer) -- (from INTEGER_REF) do create Result.make (item, other) end feature {NONE} -- Implementation abs_ref: INTEGER_REF is -- Absolute value -- (from INTEGER_REF) do if item >= 0 then Result := Current else Result := - Current end ensure -- from INTEGER_REF result_exists: Result /= void same_absolute_value: equal (Result, Current) or equal (Result, - Current) end c_ascii_char (code: INTEGER): CHARACTER is -- Character associated to integer value -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" alias "chconv" end c_outi (i: INTEGER): STRING is -- Printable representation of integer value -- (from INTEGER_REF) external "C | %"eif_out.h%"" end feature -- Bit operations bit_and (i: like Current): like Current is -- Bitwise and between Current' and i. -- Was declared in INTEGER_REF as synonym of &. -- (from INTEGER_REF) do create Result Result.set_item (eif_bit_and (item, i.item)) end bit_not: like Current is -- One's complement of Current. -- (from INTEGER_REF) do create Result Result.set_item (eif_bit_not (item)) end bit_or (i: like Current): like Current is -- Bitwise or between Current' and i. -- Was declared in INTEGER_REF as synonym of |. -- (from INTEGER_REF) do create Result Result.set_item (eif_bit_or (item, i.item)) end bit_shift (n: INTEGER): like Current is -- Shift Current from n position to right if n positive, -- to left otherwise. -- (from INTEGER_REF) require -- from INTEGER_REF n_less_or_equal_to_32: n <= 32 n_greater_or_equal_to_minus_32: n >= - 32 do if n > 0 then Result := bit_shift_right (n) else Result := bit_shift_left (- n) end end bit_shift_left (n: INTEGER): like Current is -- Shift Current from n position to left. -- Was declared in INTEGER_REF as synonym of `|<<'. -- (from INTEGER_REF) require -- from INTEGER_REF n_nonnegative: n >= 0 n_less_or_equal_to_32: n <= 32 do create Result Result.set_item (eif_bit_shift_left (item, n)) end bit_shift_right (n: INTEGER): like Current is -- Shift Current from n position to right. -- Was declared in INTEGER_REF as synonym of `|>>'. -- (from INTEGER_REF) require -- from INTEGER_REF n_nonnegative: n >= 0 n_less_or_equal_to_32: n <= 32 do create Result Result.set_item (eif_bit_shift_right (item, n)) end bit_test (n: INTEGER): BOOLEAN is -- Test n-th position of Current. -- (from INTEGER_REF) require -- from INTEGER_REF n_nonnegative: n >= 0 n_less_than_32: n < 32 do Result := eif_bit_test (item, n) end bit_xor (i: like Current): like Current is -- Bitwise xor between Current' and i. -- (from INTEGER_REF) do create Result Result.set_item (eif_bit_xor (item, i.item)) end infix "&" (i: like Current): like Current is -- Bitwise and between Current' and i. -- Was declared in INTEGER_REF as synonym of bit_and. -- (from INTEGER_REF) do create Result Result.set_item (eif_bit_and (item, i.item)) end infix "|" (i: like Current): like Current is -- Bitwise or between Current' and i. -- Was declared in INTEGER_REF as synonym of bit_or. -- (from INTEGER_REF) do create Result Result.set_item (eif_bit_or (item, i.item)) end infix "|<<" (n: INTEGER): like Current is -- Shift Current from n position to left. -- Was declared in INTEGER_REF as synonym of bit_shift_left. -- (from INTEGER_REF) require -- from INTEGER_REF n_nonnegative: n >= 0 n_less_or_equal_to_32: n <= 32 do create Result Result.set_item (eif_bit_shift_left (item, n)) end infix "|>>" (n: INTEGER): like Current is -- Shift Current from n position to right. -- Was declared in INTEGER_REF as synonym of bit_shift_right. -- (from INTEGER_REF) require -- from INTEGER_REF n_nonnegative: n >= 0 n_less_or_equal_to_32: n <= 32 do create Result Result.set_item (eif_bit_shift_right (item, n)) end feature {NONE} -- Bit operations implementation eif_bit_and (i, j: INTEGER): INTEGER is -- Bitwise and between i and j. -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" end eif_bit_not (i: INTEGER): INTEGER is -- One's complement of i. -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" end eif_bit_or (i, j: INTEGER): INTEGER is -- Bitwise or between i and j. -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" end eif_bit_shift_left (i, n: INTEGER): INTEGER is -- Shift i from n position to left. -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" end eif_bit_shift_right (i, n: INTEGER): INTEGER is -- Shift i from n position to right. -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" end eif_bit_test (i, n: INTEGER): BOOLEAN is -- Test n-th bit from i. -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" end eif_bit_xor (i, j: INTEGER): INTEGER is -- Bitwise xor between i and j. -- (from INTEGER_REF) external "C [macro %"eif_misc.h%"]" end feature -- Output out: STRING is -- Printable representation of integer value -- (from INTEGER_REF) do Result := c_outi (item) end invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) -- from INTEGER_REF sign_times_abs: sign * abs = item -- from COMPARABLE irreflexive_comparison: not (Current < Current) indexing library: "[ EiffelBase: Library of reusable components for Eiffel. ]" status: "[ Copyright 1986-2001 Interactive Software Engineering (ISE). For ISE customers the original versions are an ISE product covered by the ISE Eiffel license and support agreements. ]" license: "[ EiffelBase may now be used by anyone as FREE SOFTWARE to develop any product, public-domain or commercial, without payment to ISE, under the terms of the ISE Free Eiffel Library License (IFELL) at http://eiffel.com/products/base/license.html. ]" source: "[ Interactive Software Engineering Inc. ISE Building 360 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Electronic mail <info@eiffel.com> Customer support http://support.eiffel.com ]" info: "[ For latest info see award-winning pages: http://eiffel.com ]" end -- class INTEGER
Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:

-- Generated by ISE Eiffel --
For more details: www.eiffel.com