Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

kernel.spec.ise

Class KL_INTEGER_ROUTINES


Direct ancestors

KL_SHARED_PLATFORM, KL_IMPORTED_STRING_ROUTINES, KL_IMPORTED_ANY_ROUTINES

Features

Invariants

indexing

description

Routines that ought to be in class INTEGER

library

Gobo Eiffel Kernel Library

copyright

Copyright (c) 1999, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2005/06/29 12:42:12 $

revision

$Revision: 1.21 $

class

KL_INTEGER_ROUTINES

inherit

KL_SHARED_PLATFORM
KL_IMPORTED_STRING_ROUTINES
KL_IMPORTED_ANY_ROUTINES

feature -- Access

any_: KL_ANY_ROUTINES

-- Routines that ought to be in class ANY

-- (From KL_IMPORTED_ANY_ROUTINES)

ensure
any_routines_not_void: Result /= Void
platform: KL_PLATFORM

-- Platform-dependent properties

-- (From KL_SHARED_PLATFORM)

ensure
platform_not_void: Result /= Void
string_: KL_STRING_ROUTINES

-- Routines that ought to be in class STRING

-- (From KL_IMPORTED_STRING_ROUTINES)

ensure
string_routines_not_void: Result /= Void

feature -- Status report

is_even (an_int: INTEGER): BOOLEAN

-- Is an_int an even integer?

ensure
definition: Result = (an_int \\ 2 = 0)

feature -- Conversion

to_character (an_int: INTEGER): CHARACTER

-- Character whose code is an_int

require
an_int_large_enough: an_int >= Platform.Minimum_character_code
an_int_small_enough: an_int <= Platform.Maximum_character_code
ensure
valid_character_code: Result.code = an_int
to_decimal (an_int: INTEGER): STRING

-- Decimal representation of an_int;
-- Return a new string at each call.

ensure
decimal_not_void: Result /= Void
is_string: ANY_.same_types (Result,
)
to_hexadecimal (an_int: INTEGER; uppercase: BOOLEAN): STRING

-- Hexadecimal representation of an_int;
-- Return a new string at each call.

require
an_int_positive: an_int >= 0
ensure
hexadecimal_not_void: Result /= Void
is_string: ANY_.same_types (Result,
)
to_integer (an_int: INTEGER): INTEGER

-- Return an_int;
-- This can be used to force integer manifest constants to
-- be of INTEGER type -- some versions of SmartEiffel use
-- the smallest possible INTEGER_* type. A manifest array
-- can thus be forced to be of type ARRAY [INTEGER].

ensure
definition: Result = an_int
to_integer_8 (an_int: INTEGER): INTEGER_8

-- Convert to INTEGER_8

require
an_int_large_enouh: an_int >= -128
an_int_small_enouh: an_int <= 127
to_octal (an_int: INTEGER): STRING

-- Octal representation of an_int;
-- Return a new string at each call.

require
an_int_positive: an_int >= 0
ensure
octal_not_void: Result /= Void
is_string: ANY_.same_types (Result,
)

feature -- Output

append_decimal_integer (an_int: INTEGER; a_string: STRING)

-- Append decimal representation of an_int to a_string.
-- Note: works even when a_string is a UC_STRING.

require
a_string_not_void: a_string /= Void
append_hexadecimal_integer (an_int: INTEGER; a_string: STRING; uppercase: BOOLEAN)

-- Append a hexadecimal representation of an_int to a_string.
-- Note: works even when a_string is a UC_STRING.

require
an_int_positive: an_int >= 0
a_string_not_void: a_string /= Void
append_octal_integer (an_int: INTEGER; a_string: STRING)

-- Append octal representation of an_int to a_string.
-- Note: works even when a_string is a UC_STRING.

require
an_int_positive: an_int >= 0
a_string_not_void: a_string /= Void

feature -- Operation(s)

bit_and (m, n: INTEGER): INTEGER

-- Bitwise 'and' between m and n

bit_or (m, n: INTEGER): INTEGER

-- Bitwise 'or' between m and n

bit_shift_left (m, n: INTEGER): INTEGER

-- m shifted n bits to left;
-- Note: The new bits added on the right are 0.

require
thirty_two_bit_shift: 0 <= n and n < 32
bit_shift_right (m, n: INTEGER): INTEGER

-- m shifted n bits to right;
-- Note: If the first bit of m is set (i.e. the sign bit), then
-- the new bits added on the left are 1; otherwise they are 0.

require
thirty_two_bit_shift: 0 <= n and n < 32
div (x, n: INTEGER): INTEGER

-- Integer division of x by n
-- (Use ISO C99 specification)

require
divisible: n /= 0
overflow: x = Platform.Minimum_integer implies n /= -1
ensure
definition: Result * n + mod (x, n) = x
mod (x, n: INTEGER): INTEGER

-- Reminder of the integer division of x by n
-- (Use ISO C99 specification)

require
divisible: n /= 0
ensure
definition1: n /= Platform.Minimum_integer implies Result.abs < n.abs
definition2: n = Platform.Minimum_integer implies Result.abs <= Platform.Maximum_integer
iso_c99: Result /= 0 implies Result.sign = x.sign
power (x, n: INTEGER): INTEGER

-- Integer x to the power of n (x ^ n)

require
positive_n: n >= 0
ensure
zero_power_n: x = 0 and n /= 0 implies Result = 0
x_power_0: n = 0 implies Result = 1
recursive_definition: n > 0 implies (Result = x * power (x, n - 1))

feature -- Obsolete

platform_: KL_PLATFORM

-- Platform-dependent properties

-- (From KL_SHARED_PLATFORM)

obsolete

[040101] Use Platform instead.

ensure
platform_not_void: Result /= Void

invariant


-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end