indexing
	description: "Integer values coded on 16 bits"
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

expanded class interface
	INTEGER_16

feature -- Access

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

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

	item: INTEGER_16
			-- Integer value
			-- (from INTEGER_16_REF)

	one: like Current
			-- Neutral element for "*" and "/"
			-- (from INTEGER_16_REF)
		ensure -- from NUMERIC
			result_exists: Result /= void

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

	zero: like Current
			-- Neutral element for "+" and "-"
			-- (from INTEGER_16_REF)
		ensure -- from NUMERIC
			result_exists: Result /= void
	
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_16_REF)
		require -- from ANY
			other_not_void: other /= void
		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))

	max (other: like Current): like Current
			-- The greater of current object and other
			-- (from COMPARABLE)
		require -- from COMPARABLE
			other_exists: other /= void
		ensure -- from COMPARABLE
			current_if_not_smaller: Current >= other implies Result = Current
			other_if_smaller: Current < other implies Result = other

	min (other: like Current): like Current
			-- The smaller of current object and other
			-- (from COMPARABLE)
		require -- from COMPARABLE
			other_exists: other /= void
		ensure -- from COMPARABLE
			current_if_not_greater: Current <= other implies Result = Current
			other_if_greater: Current > other implies Result = other

	three_way_comparison (other: INTEGER_16_REF): INTEGER
			-- If current object equal to other, 0
			-- if smaller, -1; if greater, 1
			-- (from INTEGER_16_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_16_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_16_REF): BOOLEAN
			-- May current object be divided by other?
			-- (from INTEGER_16_REF)
		require -- from NUMERIC
			other_exists: other /= void
		ensure then -- from INTEGER_16_REF
			value: Result = (other.item /= 0)

	exponentiable (other: NUMERIC): BOOLEAN
			-- May current object be elevated to the power other?
			-- (from INTEGER_16_REF)
		require -- from NUMERIC
			other_exists: other /= void
		ensure then -- from INTEGER_16_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_16_REF)
		ensure -- from HASHABLE
			ok_if_not_default: Result implies (Current /= default)
	
feature -- Element change

	set_item (i: INTEGER_16)
			-- Make i the item value.
			-- (from INTEGER_16_REF)
	
feature -- Conversion

	to_integer: INTEGER
			-- Convert item into an INTEGER_32 value.
			-- (from INTEGER_16_REF)

	to_integer_64: INTEGER_64
			-- Convert item into an INTEGER_64 value.
			-- (from INTEGER_16_REF)

	to_integer_8: INTEGER_8
			-- Convert item into an INTEGER_8 value.
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			not_too_small: item >= - 128
			not_too_big: item <= 127
	
feature -- Basic operations

	abs: INTEGER_16
			-- Absolute value
			-- (from INTEGER_16_REF)
		ensure -- from INTEGER_16_REF
			non_negative: Result >= 0
			same_absolute_value: (Result = item) or (Result = - item)

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

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

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

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

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

	infix "/" (other: like Current): DOUBLE
			-- Division by other
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			other_exists: other /= void
			good_divisor: divisible (other)

	infix "//" (other: like Current): like Current
			-- Integer division of Current by other
			-- (from INTEGER_16_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_16_REF)
		require -- from INTEGER_16_REF
			other_exists: other /= void
			good_divisor: divisible (other)
		ensure -- from INTEGER_16_REF
			result_exists: Result /= void

	infix "^" (other: NUMERIC): DOUBLE
			-- Integer power of Current by other
			-- (from INTEGER_16_REF)

	infix "|..|" (other: INTEGER_16): INTEGER_INTERVAL
			-- Interval from current element to other
			-- (empty if other less than current integer)
			-- (from INTEGER_16_REF)
	
feature -- Bit operations

	bit_and (i: like Current): like Current
			-- Bitwise and between Current' and i.
			-- Was declared in INTEGER_16_REF as synonym of &.
			-- (from INTEGER_16_REF)

	bit_not: like Current
			-- One's complement of Current.
			-- (from INTEGER_16_REF)

	bit_or (i: like Current): like Current
			-- Bitwise or between Current' and i.
			-- Was declared in INTEGER_16_REF as synonym of |.
			-- (from INTEGER_16_REF)

	bit_shift (n: INTEGER): like Current
			-- Shift Current from n position to right if n positive,
			-- to left otherwise.
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			n_less_or_equal_to_16: n <= 16
			n_greater_or_equal_to_minus_16: n >= - 16

	bit_shift_left (n: INTEGER): like Current
			-- Shift Current from n position to left.
			-- Was declared in INTEGER_16_REF as synonym of `|<<'.
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			n_nonnegative: n >= 0
			n_less_or_equal_to_16: n <= 16

	bit_shift_right (n: INTEGER): like Current
			-- Shift Current from n position to right.
			-- Was declared in INTEGER_16_REF as synonym of `|>>'.
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			n_nonnegative: n >= 0
			n_less_or_equal_to_16: n <= 16

	bit_test (n: INTEGER): BOOLEAN
			-- Test n-th position of Current.
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			n_nonnegative: n >= 0
			n_less_than_16: n < 16

	bit_xor (i: like Current): like Current
			-- Bitwise xor between Current' and i.
			-- (from INTEGER_16_REF)

	infix "&" (i: like Current): like Current
			-- Bitwise and between Current' and i.
			-- Was declared in INTEGER_16_REF as synonym of bit_and.
			-- (from INTEGER_16_REF)

	infix "|" (i: like Current): like Current
			-- Bitwise or between Current' and i.
			-- Was declared in INTEGER_16_REF as synonym of bit_or.
			-- (from INTEGER_16_REF)

	infix "|<<" (n: INTEGER): like Current
			-- Shift Current from n position to left.
			-- Was declared in INTEGER_16_REF as synonym of bit_shift_left.
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			n_nonnegative: n >= 0
			n_less_or_equal_to_16: n <= 16

	infix "|>>" (n: INTEGER): like Current
			-- Shift Current from n position to right.
			-- Was declared in INTEGER_16_REF as synonym of bit_shift_right.
			-- (from INTEGER_16_REF)
		require -- from INTEGER_16_REF
			n_nonnegative: n >= 0
			n_less_or_equal_to_16: n <= 16
	
feature -- Output

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

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)
		-- from INTEGER_16_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_16