Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:
indexing description: "Real values, double precision" status: "See notice at end of class" date: "$Date: 2001-11-16 20:32:23 +0000 (Fri, 16 Nov 2001) $" revision: "$Revision: 51435 $" expanded class DOUBLE feature -- Access hash_code: INTEGER is -- Hash code value -- (from DOUBLE_REF) do Result := truncated_to_integer.hash_code ensure -- from HASHABLE good_hash_value: Result >= 0 end item: DOUBLE -- Numeric double value -- (from DOUBLE_REF) one: like Current is -- Neutral element for "*" and "/" -- (from DOUBLE_REF) do create Result Result.set_item (1.0) ensure -- from NUMERIC result_exists: Result /= void end sign: INTEGER is -- Sign value (0, -1 or 1) -- (from DOUBLE_REF) do if item > 0.0 then Result := 1 elseif item < 0.0 then Result := - 1 end ensure -- from DOUBLE_REF three_way: Result = three_way_comparison (zero) end zero: like Current is -- Neutral element for "+" and "-" -- (from DOUBLE_REF) do create Result Result.set_item (0.0) ensure -- from NUMERIC result_exists: Result /= void end feature -- Comparison is_equal (other: like Current): BOOLEAN is -- Is other attached to an object of the same type -- as current object and identical to it? -- (from DOUBLE_REF) require -- from ANY other_not_void: other /= void do Result := other.item = item 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)) end max (other: like Current): like Current is -- The greater of current object and other -- (from COMPARABLE) require -- from COMPARABLE other_exists: other /= void do if Current >= other then Result := Current else Result := other end ensure -- from COMPARABLE current_if_not_smaller: Current >= other implies Result = Current other_if_smaller: Current < other implies Result = other end min (other: like Current): like Current is -- The smaller of current object and other -- (from COMPARABLE) require -- from COMPARABLE other_exists: other /= void do if Current <= other then Result := Current else Result := other end ensure -- from COMPARABLE current_if_not_greater: Current <= other implies Result = Current other_if_greater: Current > other implies Result = other end three_way_comparison (other: DOUBLE_REF): INTEGER is -- If current object equal to other, 0; -- if smaller, -1; if greater, 1 -- (from DOUBLE_REF) require -- from COMPARABLE other_exists: other /= void do if item < other.item then Result := - 1 elseif other.item < item then Result := 1 end ensure -- from COMPARABLE equal_zero: (Result = 0) = is_equal (other) smaller_negative: (Result = - 1) = (Current < other) greater_positive: (Result = 1) = (Current > other) end infix "<" (other: like Current): BOOLEAN is -- Is other greater than current double? -- (from DOUBLE_REF) require -- from PART_COMPARABLE other_exists: other /= void do Result := item < other.item ensure then -- from COMPARABLE asymmetric: Result implies not (other < Current) end infix "<=" (other: like Current): BOOLEAN is -- Is current object less than or equal to other? -- (from COMPARABLE) require -- from PART_COMPARABLE other_exists: other /= void do Result := not (other < Current) ensure then -- from COMPARABLE definition: Result = ((Current < other) or is_equal (other)) end infix ">" (other: like Current): BOOLEAN is -- Is current object greater than other? -- (from COMPARABLE) require -- from PART_COMPARABLE other_exists: other /= void do Result := other < Current ensure then -- from COMPARABLE definition: Result = (other < Current) end infix ">=" (other: like Current): BOOLEAN is -- Is current object greater than or equal to other? -- (from COMPARABLE) require -- from PART_COMPARABLE other_exists: other /= void do Result := not (Current < other) ensure then -- from COMPARABLE definition: Result = (other <= Current) end feature -- Status report divisible (other: DOUBLE_REF): BOOLEAN is -- May current object be divided by other? -- (from DOUBLE_REF) require -- from NUMERIC other_exists: other /= void do Result := other.item /= 0.0 ensure then -- from DOUBLE_REF not_exact_zero: Result implies (other.item /= 0.0) end exponentiable (other: NUMERIC): BOOLEAN is -- May current object be elevated to the power other? -- (from DOUBLE_REF) require -- from NUMERIC other_exists: other /= void local integer_value: INTEGER_REF double_value: DOUBLE_REF real_value: REAL_REF do integer_value ?= other real_value ?= other double_value ?= other if integer_value /= void then Result := integer_value.item >= 0 or item /= 0.0 elseif real_value /= void then Result := real_value.item >= 0.0 or item /= 0.0 elseif double_value /= void then Result := double_value.item >= 0.0 or item /= 0.0 end ensure then -- from DOUBLE_REF safe_values: ((other.conforms_to (0) and item /= 0.0) or (other.conforms_to (0.0) and item > 0.0)) implies Result end is_hashable: BOOLEAN is -- May current object be hashed? -- (True if it is not its type's default.) -- (from DOUBLE_REF) do Result := item /= 0.0 ensure -- from HASHABLE ok_if_not_default: Result implies (Current /= default) end feature -- Element change set_item (d: DOUBLE) is -- Make d the item value. -- (from DOUBLE_REF) do item := d end feature -- Conversion ceiling: INTEGER is -- Smallest integral value no smaller than current object -- (from DOUBLE_REF) do Result := c_ceiling (item).truncated_to_integer ensure -- from DOUBLE_REF result_no_smaller: Result >= item close_enough: Result - item < item.one end floor: INTEGER is -- Greatest integral value no greater than current object -- (from DOUBLE_REF) do Result := c_floor (item).truncated_to_integer ensure -- from DOUBLE_REF result_no_greater: Result <= item close_enough: item - Result < Result.one end rounded: INTEGER is -- Rounded integral value -- (from DOUBLE_REF) do Result := sign * (c_floor (abs_ref.item + 0.5).truncated_to_integer) ensure -- from DOUBLE_REF definition: Result = sign * ((abs + 0.5).floor) end truncated_to_integer: INTEGER is -- Integer part (Same sign, largest absolute -- value no greater than current object's) -- (from DOUBLE_REF) do Result := c_truncated_to_integer (item) end truncated_to_real: REAL is -- Real part (Same sign, largest absolute -- value no greater than current object's) -- (from DOUBLE_REF) do Result := c_truncated_to_real (item) end feature -- Basic operations abs: DOUBLE is -- Absolute value -- (from DOUBLE_REF) do Result := abs_ref.item ensure -- from DOUBLE_REF non_negative: Result >= 0.0 same_absolute_value: (Result = item) or (Result = - item) end infix "*" (other: like Current): like Current is -- Product with other -- (from DOUBLE_REF) require -- from NUMERIC other_exists: other /= void do create Result Result.set_item (item * other.item) ensure -- from NUMERIC result_exists: Result /= void end prefix "+": like Current is -- Unary plus -- (from DOUBLE_REF) do create Result Result.set_item (+ item) ensure -- from NUMERIC result_exists: Result /= void end infix "+" (other: like Current): like Current is -- Sum with other -- (from DOUBLE_REF) require -- from NUMERIC other_exists: other /= void do create Result Result.set_item (item + other.item) ensure -- from NUMERIC result_exists: Result /= void commutative: equal (Result, other + Current) end prefix "-": like Current is -- Unary minus -- (from DOUBLE_REF) do create Result Result.set_item (- item) ensure -- from NUMERIC result_exists: Result /= void end infix "-" (other: like Current): like Current is -- Result of subtracting other -- (from DOUBLE_REF) require -- from NUMERIC other_exists: other /= void do create Result Result.set_item (item - other.item) ensure -- from NUMERIC result_exists: Result /= void end infix "/" (other: like Current): like Current is -- Division by other -- (from DOUBLE_REF) require -- from NUMERIC other_exists: other /= void good_divisor: divisible (other) do create Result Result.set_item (item / other.item) ensure -- from NUMERIC result_exists: Result /= void end infix "^" (other: NUMERIC): DOUBLE is -- Current double to the power other -- (from DOUBLE_REF) local integer_value: INTEGER_REF real_value: REAL_REF double_value: DOUBLE_REF do integer_value ?= other real_value ?= other double_value ?= other if integer_value /= void then Result := item ^ integer_value.item elseif real_value /= void then Result := item ^ real_value.item elseif double_value /= void then Result := item ^ double_value.item end end feature {NONE} -- Implementation abs_ref: DOUBLE_REF is -- Absolute value -- (from DOUBLE_REF) do if item >= 0.0 then Result := Current else Result := - Current end ensure -- from DOUBLE_REF result_exists: Result /= void same_absolute_value: equal (Result, Current) or equal (Result, - Current) end c_ceiling (d: DOUBLE): DOUBLE is -- Smallest integral value no smaller than d -- (from DOUBLE_REF) external "C | <math.h>" alias "ceil" end c_floor (d: DOUBLE): DOUBLE is -- Greatest integral value no greater than d -- (from DOUBLE_REF) external "C | <math.h>" alias "floor" end c_outd (d: DOUBLE): STRING is -- Printable representation of double value -- (from DOUBLE_REF) external "C | %"eif_out.h%"" end c_truncated_to_integer (d: DOUBLE): INTEGER is -- Integer part of d (same sign, largest absolute -- value no greater than d's) -- (from DOUBLE_REF) external "C [macro %"eif_misc.h%"]" alias "conv_di" end c_truncated_to_real (d: DOUBLE): REAL is -- Real part of d (same sign, largest absolute -- value no greater than d's) -- (from DOUBLE_REF) external "C [macro %"eif_misc.h%"]" alias "conv_dr" end feature -- Output out: STRING is -- Printable representation of double value -- (from DOUBLE_REF) do Result := c_outd (item) end invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) -- from DOUBLE_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 DOUBLE
Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:

-- Generated by ISE Eiffel --
For more details: www.eiffel.com