1 
indexing 
2 

3 
description: 
4 
"Objects to which numerical operations are applicable" 
5 

6 
note: "The model is that of a commutative ring." 
7 
status: "See notice at end of class" 
8 
date: "$Date$" 
9 
revision: "$Revision$" 
10 

11 
deferred class 
12 

13 
NUMERIC 
14 

15 
inherit 
16 
DEBUG_OUTPUT 
17 
rename 
18 
debug_output as out 
19 
end 
20 

21 
feature  Access 
22 

23 
one: like Current is 
24 
 Neutral element for "*" and "/" 
25 
deferred 
26 
ensure 
27 
result_exists: Result /= Void 
28 
end 
29 

30 
zero: like Current is 
31 
 Neutral element for "+" and "" 
32 
deferred 
33 
ensure 
34 
result_exists: Result /= Void 
35 
end 
36 

37 
feature  Status report 
38 

39 
divisible (other: like Current): BOOLEAN is 
40 
 May current object be divided by `other'? 
41 
require 
42 
other_exists: other /= Void 
43 
deferred 
44 
end 
45 

46 
exponentiable (other: NUMERIC): BOOLEAN is 
47 
 May current object be elevated to the power `other'? 
48 
require 
49 
other_exists: other /= Void 
50 
deferred 
51 
end 
52 

53 
feature  Basic operations 
54 

55 
infix "+" (other: like Current): like Current is 
56 
 Sum with `other' (commutative). 
57 
require 
58 
other_exists: other /= Void 
59 
deferred 
60 
ensure 
61 
result_exists: Result /= Void 
62 
commutative: equal (Result, other + Current) 
63 
end 
64 

65 
infix "" (other: like Current): like Current is 
66 
 Result of subtracting `other' 
67 
require 
68 
other_exists: other /= Void 
69 
deferred 
70 
ensure 
71 
result_exists: Result /= Void 
72 
end 
73 

74 
infix "*" (other: like Current): like Current is 
75 
 Product by `other' 
76 
require 
77 
other_exists: other /= Void 
78 
deferred 
79 
ensure 
80 
result_exists: Result /= Void 
81 
end 
82 

83 
infix "/" (other: like Current): like Current is 
84 
 Division by `other' 
85 
require 
86 
other_exists: other /= Void 
87 
good_divisor: divisible (other) 
88 
deferred 
89 
ensure 
90 
result_exists: Result /= Void 
91 
end 
92 

93 
prefix "+": like Current is 
94 
 Unary plus 
95 
deferred 
96 
ensure 
97 
result_exists: Result /= Void 
98 
end 
99 

100 
prefix "": like Current is 
101 
 Unary minus 
102 
deferred 
103 
ensure 
104 
result_exists: Result /= Void 
105 
end 
106 

107 
invariant 
108 

109 
 neutral_addition: equal (Current + zero, Current); 
110 
 self_subtraction: equal (Current  Current, zero); 
111 
 neutral_multiplication: equal (Current * one, Current); 
112 
 self_division: divisible (Current) implies equal (Current / Current, one) 
113 

114 
indexing 
115 

116 
library: "[ 
117 
EiffelBase: Library of reusable components for Eiffel. 
118 
]" 
119 

120 
status: "[ 
121 
Copyright 19862001 Interactive Software Engineering (ISE). 
122 
For ISE customers the original versions are an ISE product 
123 
covered by the ISE Eiffel license and support agreements. 
124 
]" 
125 

126 
license: "[ 
127 
EiffelBase may now be used by anyone as FREE SOFTWARE to 
128 
develop any product, publicdomain or commercial, without 
129 
payment to ISE, under the terms of the ISE Free Eiffel Library 
130 
License (IFELL) at http://eiffel.com/products/base/license.html. 
131 
]" 
132 

133 
source: "[ 
134 
Interactive Software Engineering Inc. 
135 
ISE Building 
136 
360 Storke Road, Goleta, CA 93117 USA 
137 
Telephone 8056851006, Fax 8056856869 
138 
Electronic mail <info@eiffel.com> 
139 
Customer support http://support.eiffel.com 
140 
]" 
141 

142 
info: "[ 
143 
For latest info see awardwinning pages: http://eiffel.com 
144 
]" 
145 

146 
end  class NUMERIC 
147 

148 

149 

150 
