note description: "References to objects containing an unsigned integer value coded on 8 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_8_REF create default_create feature -- Access item: NATURAL_8 -- 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_8 = 0 Max_value: NATURAL_8 = 255 -- 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_8) -- 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.to_integer_32 >= {CHARACTER_8}.min_value and item.to_integer_32 <= {CHARACTER_8}.max_value) is_valid_character_32_code: BOOLEAN -- Does current object represent a CHARACTER_32? ensure in_bounds: Result = (item.to_natural_32 >= {CHARACTER_32}.min_value and item.to_natural_32 <= {CHARACTER_32}.max_value) 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. interval alias "|..|" (other: INTEGER_32): INTEGER_INTERVAL -- Interval from current element to other -- (empty if other less than current integer) feature -- Conversion to_reference: NATURAL_8_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. frozen to_natural_16: NATURAL_16 -- item converted into a NATURAL_16 value. frozen to_natural_32: NATURAL_32 -- item converted into a NATURAL_32 value. 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_8 frozen to_integer_16: INTEGER_16 -- item converted into an INTEGER_16 value. frozen to_integer_32: INTEGER_32 -- item converted into an INTEGER_32 value. frozen to_integer_64: INTEGER_64 -- item converted into an INTEGER_64 value. 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 = 2 to_hex_character: CHARACTER_8 -- item converted into a hexadecimal character. require in_bounds: 0 <= item.to_integer_32 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_8 -- Current shifted from n position to right if n positive, -- to left otherwise. require n_less_or_equal_to_8: n <= 8 n_greater_or_equal_to_minus_8: n >= -8 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_8: n <= 8 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_8: n <= 8 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_8: n < 8 frozen set_bit (b: BOOLEAN; n: INTEGER_32): NATURAL_8 -- Copy of current with n-th position -- set to 1 if b, 0 otherwise. require n_nonnegative: n >= 0 n_less_than_8: n < 8 frozen set_bit_with_mask (b: BOOLEAN; m: NATURAL_8): NATURAL_8 -- 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_8_REF
Generated by ISE EiffelStudio