indexing
	description: "Integer values"

expanded class interface
	INTEGER

feature -- Access

	ascii_char: CHARACTER
			-- Returns corresponding ASCII character to item value.
			-- (from INTEGER_REF)

	hash_code: INTEGER
			-- Hash code value
			-- (from INTEGER_REF)
		ensure -- from HASHABLE
			good_hash_value: Result >= 0

	item: INTEGER
			-- Integer value
			-- (from INTEGER_REF)

	one: INTEGER
			-- Neutral element for "*" and "/"
			-- (from INTEGER_REF)
		ensure -- from INTEGER_REF
			value: Result = 1

	sign: INTEGER
			-- Sign value (0, -1 or 1)
			-- (from INTEGER_REF)
		ensure -- from INTEGER_REF
			three_way: Result = three_way_comparison (zero)

	zero: INTEGER
			-- Neutral element for "+" and "-"
			-- (from INTEGER_REF)
		ensure -- from INTEGER_REF
			value: Result = 0
	
feature -- Comparison

	is_equal (other: like Current): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object and identical to it?
			-- (from INTEGER_REF)
		require -- COMPARABLE
			precursor: True
		require -- from GENERAL
			other_not_void: other /= void
		ensure then -- from COMPARABLE
			trichotomy: Result = (not (Current < other) and not (other < Current))
		ensure -- from GENERAL
			symmetric: Result implies other.is_equal (Current);
			consistent: standard_is_equal (other) implies Result

	max (other: INTEGER_REF): INTEGER
			-- The greater of current object and other
			-- (from INTEGER_REF)
		require -- from INTEGER_REF
			other_exists: other /= void

	min (other: INTEGER_REF): INTEGER
			-- The smaller of current object and other
			-- (from INTEGER_REF)
		require -- from INTEGER_REF
			other_exists: other /= void

	three_way_comparison (other: INTEGER_REF): INTEGER
			-- If current object equal to other, 0;
			-- if smaller, -1; if greater, 1
			-- (from INTEGER_REF)
		require -- from COMPARABLE
			other_exists: other /= void
		ensure -- from COMPARABLE
			equal_zero: (Result = 0) = is_equal (other);
			smaller_negative: (Result = - 1) = (Current < other);
			greater_positive: (Result = 1) = (Current > other)

	infix "<" (other: like Current): BOOLEAN
			-- Is current integer less than other?
			-- (from INTEGER_REF)
		require -- from PART_COMPARABLE
			other_exists: other /= void
		ensure then -- from COMPARABLE
			asymmetric: Result implies not (other < Current)

	infix "<=" (other: like Current): BOOLEAN
			-- Is current object less than or equal to other?
			-- (from COMPARABLE)
		require -- from PART_COMPARABLE
			other_exists: other /= void
		ensure then -- from COMPARABLE
			definition: Result = ((Current < other) or is_equal (other))

	infix ">" (other: like Current): BOOLEAN
			-- Is current object greater than other?
			-- (from COMPARABLE)
		require -- from PART_COMPARABLE
			other_exists: other /= void
		ensure then -- from COMPARABLE
			definition: Result = (other < Current)

	infix ">=" (other: like Current): BOOLEAN
			-- Is current object greater than or equal to other?
			-- (from COMPARABLE)
		require -- from PART_COMPARABLE
			other_exists: other /= void
		ensure then -- from COMPARABLE
			definition: Result = (other <= Current)
	
feature -- Status report

	divisible (other: INTEGER_REF): BOOLEAN
			-- May current object be divided by other?
			-- (from INTEGER_REF)
		require -- from NUMERIC
			other_exists: other /= void
		ensure then -- from INTEGER_REF
			value: Result = (other.item /= 0)

	exponentiable (other: NUMERIC): BOOLEAN
			-- May current object be elevated to the power other?
			-- (from INTEGER_REF)
		require -- from NUMERIC
			other_exists: other /= void
		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

	is_hashable: BOOLEAN
			-- May current object be hashed?
			-- (True if it is not its type's default.)
			-- (from INTEGER_REF)
		ensure -- from HASHABLE
			ok_if_not_default: Result implies (Current /= default)
	
feature -- Element change

	set_item (i: INTEGER)
			-- Make i the item value.
			-- (from INTEGER_REF)
	
feature -- Basic operations

	abs: INTEGER
			-- Absolute value
			-- (from INTEGER_REF)
		ensure -- from INTEGER_REF
			non_negative: Result >= 0;
			same_absolute_value: (Result = item) or (Result = - item)

	infix "*" (other: like Current): like Current
			-- Product by other
			-- (from INTEGER_REF)
		require -- from NUMERIC
			other_exists: other /= void
		ensure -- from NUMERIC
			result_exists: Result /= void

	infix "+" (other: like Current): like Current
			-- Sum with other
			-- (from INTEGER_REF)
		require -- from NUMERIC
			other_exists: other /= void
		ensure -- from NUMERIC
			result_exists: Result /= void;
			commutative: equal (Result, other + Current)

	prefix "+ ": like Current
			-- Unary plus
			-- (from INTEGER_REF)
		ensure -- from NUMERIC
			result_exists: Result /= void

	infix "-" (other: like Current): like Current
			-- Result of subtracting other
			-- (from INTEGER_REF)
		require -- from NUMERIC
			other_exists: other /= void
		ensure -- from NUMERIC
			result_exists: Result /= void

	prefix "- ": like Current
			-- Unary minus
			-- (from INTEGER_REF)
		ensure -- from NUMERIC
			result_exists: Result /= void

	infix "/" (other: like Current): DOUBLE
			-- Division by other
		require -- from INTEGER_REF
			other_exists: other /= void;
			good_divisor: divisible (other)
		ensure -- from INTEGER_REF
			result_exists: Result /= void

	infix "//" (other: like Current): like Current
			-- Integer division of Current by other
			-- (from INTEGER_REF)
		require -- from NUMERIC
			other_exists: other /= void;
			good_divisor: divisible (other)
		ensure -- from NUMERIC
			result_exists: Result /= void

	infix "\\" (other: like Current): like Current
			-- Remainder of the integer division of Current by other
			-- (from INTEGER_REF)
		require -- from INTEGER_REF
			other_exists: other /= void;
			good_divisor: divisible (other)
		ensure -- from INTEGER_REF
			result_exists: Result /= void

	infix "^" (other: NUMERIC): DOUBLE
			-- Integer power of Current by other
		require -- from NUMERIC
			other_exists: other /= void;
			good_exponent: exponentiable (other)
		ensure -- from NUMERIC
			result_exists: Result /= void
	
feature -- Output

	out: STRING
			-- Printable representation of integer value
			-- (from INTEGER_REF)
	
invariant

		-- from GENERAL
	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);

end -- class INTEGER