note
	description: "References to objects containing an unsigned integer value coded on 64 bits."
	library: "Free implementation of ELKS library"
	status: "See notice at end of class."
	legal: "See notice at end of class."
	date: "$Date: 2020-05-19 14:18:09 +0000 (Tue, 19 May 2020) $"
	revision: "$Revision: 104255 $"

class interface
	NATURAL_64_REF

create 
	default_create

feature -- Access

	item: NATURAL_64
			-- Value.

	hash_code: INTEGER_32
			-- Hash code value.

	sign: INTEGER_32
			-- Sign value (0 or 1).
		ensure
			three_way: Result = three_way_comparison (zero)

	one: like Current
			-- Neutral element for "*" and "/".

	zero: like Current
			-- Neutral element for "+" and "-".

	Min_value: NATURAL_64 = 0

	Max_value: NATURAL_64 = 18446744073709551615
			-- Minimum and Maximum value hold in item.
	
feature -- Comparison

	is_less alias "<" (other: like Current): BOOLEAN
			-- Is current integer less than other?

	is_equal (other: like Current): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object and identical to it?
	
feature -- Element change

	set_item (i: NATURAL_64)
			-- Make i the item value.
		ensure
			item_set: item = i
	
feature -- Status report

	divisible (other: like Current): BOOLEAN
			-- May current object be divided by other?
		ensure then
			value: Result = (other.item /= 0)

	exponentiable (other: NUMERIC): BOOLEAN
			-- May current object be elevated to the power other?
		ensure then
			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.)

	is_valid_character_8_code: BOOLEAN
			-- Does current object represent a CHARACTER_8?
		ensure
			in_bounds: Result = (item >= {CHARACTER_8}.min_value.to_natural_64 and item <= {CHARACTER_8}.max_value.to_natural_64)

	is_valid_character_32_code: BOOLEAN
			-- Does current object represent a CHARACTER_32?
		ensure
			in_bounds: Result = (item >= {CHARACTER_32}.min_value.to_natural_64 and item <= {CHARACTER_32}.max_value.to_natural_64)
	
feature -- Basic operations

	plus alias "+" (other: like Current): like Current
			-- Sum with other.

	minus alias "-" alias "" (other: like Current): like Current
			-- Result of subtracting other.

	product alias "*" alias "×" (other: like Current): like Current
			-- Product by other.

	quotient alias "/" alias "÷" (other: like Current): REAL_64
			-- Division by other.
		require
			other_exists: other /= Void
			good_divisor: divisible (other)

	identity alias "+": like Current
			-- Unary plus.

	unapplicable_opposite: like Current
			-- Unary minus.
		ensure then
			not_applicable: False

	integer_quotient alias "//" (other: like Current): like Current
			-- Integer division of Current by other.

	integer_remainder alias "\\" (other: like Current): like Current
			-- Remainder of the integer division of Current by other.
		require
			other_exists: other /= Void
			good_divisor: divisible (other)
		ensure
			result_exists: Result /= Void

	power alias "^" (other: REAL_64): REAL_64
			-- Integer power of Current by other.
	
feature -- Conversion

	to_reference: NATURAL_64_REF
			-- Associated reference of Current.
		ensure
			to_reference_not_void: Result /= Void

	frozen to_boolean: BOOLEAN
			-- True if not zero.

	as_natural_8: NATURAL_8
			-- item converted into a NATURAL_8 value.

	as_natural_16: NATURAL_16
			-- item converted into a NATURAL_16 value.

	as_natural_32: NATURAL_32
			-- item converted into a NATURAL_32 value.

	as_natural_64: NATURAL_64
			-- item converted into a NATURAL_64 value.

	as_integer_8: INTEGER_8
			-- item converted into an INTEGER_8 value.

	as_integer_16: INTEGER_16
			-- item converted into an INTEGER_16 value.

	as_integer_32: INTEGER_32
			-- item converted into an INTEGER_32 value.

	as_integer_64: INTEGER_64
			-- item converted into an INTEGER_64 value.

	frozen to_natural_8: NATURAL_8
			-- item converted into a NATURAL_8 value.
		require
			not_too_big: item <= {NATURAL_8}.max_value.to_natural_64

	frozen to_natural_16: NATURAL_16
			-- item converted into a NATURAL_16 value.
		require
			not_too_big: item <= {NATURAL_16}.max_value.to_natural_64

	frozen to_natural_32: NATURAL_32
			-- item converted into a NATURAL_32 value.
		require
			not_too_big: item <= {NATURAL_32}.max_value.to_natural_64

	frozen to_natural_64: NATURAL_64
			-- item converted into a NATURAL_64 value.

	frozen to_integer_8: INTEGER_8
			-- item converted into an INTEGER_8 value.
		require
			not_too_big: item <= {INTEGER_8}.max_value.to_natural_64

	frozen to_integer_16: INTEGER_16
			-- item converted into an INTEGER_16 value.
		require
			not_too_big: item <= {INTEGER_16}.max_value.to_natural_64

	frozen to_integer_32: INTEGER_32
			-- item converted into an INTEGER_32 value.
		require
			not_too_big: item <= {INTEGER_32}.max_value.to_natural_64

	frozen to_integer_64: INTEGER_64
			-- item converted into an INTEGER_64 value.
		require
			not_too_big: item <= {INTEGER_64}.max_value.to_natural_64

	to_real_32: REAL_32
			-- item converted into a REAL_32.

	to_real_64: REAL_64
			-- item converted into a REAL_64.

	to_hex_string: STRING_8
			-- item converted into a hexadecimal string.
		ensure
			result_not_void: Result /= Void
			result_valid_count: Result.count = {PLATFORM}.integer_64_bits // 4

	to_hex_character: CHARACTER_8
			-- item converted into a hexadecimal character.
		require
			in_bounds: 0 <= item and item <= 15
		ensure
			valid_character: ("0123456789ABCDEF").has (Result)

	to_character_8: CHARACTER_8
			-- Associated character in 8 bit version.
		require
			valid_character: is_valid_character_8_code

	to_character_32: CHARACTER_32
			-- Associated character in 32 bit version.
		require
			valid_character: is_valid_character_32_code
	
feature -- Bit operations

	bit_and alias "&" alias "" (i: like Current): like Current
			-- Bitwise "and" between Current and i.
		require
			i_not_void: i /= Void
		ensure
			bitwise_and_not_void: Result /= Void

	bit_or alias "|" alias "" (i: like Current): like Current
			-- Bitwise "or" between Current and i.
		require
			i_not_void: i /= Void
		ensure
			bitwise_or_not_void: Result /= Void

	bit_xor alias "" (i: like Current): like Current
			-- Bitwise "xor" between Current and i.
		require
			i_not_void: i /= Void
		ensure
			bitwise_xor_not_void: Result /= Void

	bit_not alias "": like Current
			-- One's complement of Current.
		ensure
			bit_not_not_void: Result /= Void

	frozen bit_shift (n: INTEGER_32): NATURAL_64
			-- Current shifted from n position to right if n positive,
			-- to left otherwise.
		require
			n_less_or_equal_to_64: n <= 64
			n_greater_or_equal_to_minus_64: n >= -64

	bit_shift_left alias "|<<" alias "" (n: INTEGER_32): like Current
			-- Current shifted from n position to left.
		require
			n_nonnegative: n >= 0
			n_less_or_equal_to_64: n <= 64
		ensure
			bit_shift_left_not_void: Result /= Void

	bit_shift_right alias "|>>" alias "" (n: INTEGER_32): like Current
			-- Current shifted from n position to right.
		require
			n_nonnegative: n >= 0
			n_less_or_equal_to_64: n <= 64
		ensure
			bit_shift_right_not_void: Result /= Void

	frozen bit_test (n: INTEGER_32): BOOLEAN
			-- Test n-th position of Current.
		require
			n_nonnegative: n >= 0
			n_less_than_64: n < 64

	frozen set_bit (b: BOOLEAN; n: INTEGER_32): NATURAL_64
			-- Copy of current with n-th position
			-- set to 1 if b, 0 otherwise.
		require
			n_nonnegative: n >= 0
			n_less_than_64: n < 64

	frozen set_bit_with_mask (b: BOOLEAN; m: NATURAL_64): NATURAL_64
			-- Copy of current with all 1 bits of m set to 1
			-- if b, 0 otherwise.
	
feature -- Output

	out: STRING_8
			-- Printable representation of value.
	
note
	copyright: "Copyright (c) 1984-2020, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		5949 Hollister Ave., Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class NATURAL_64_REF

Generated by ISE EiffelStudio