2 Copyright (c) 2008 Vincent Geddes
3 Copyright (c) 2008 Luca Bruno
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the 'Software'), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 DEALINGS IN THE SOFTWARE.
28 self shouldNotImplement!
75 self < self zero ifTrue: [^ -1].
76 self > self zero ifTrue: [^ 1].
83 "Create an Interval between the receiver and stop"
84 ^ Interval from: self to: stop!
88 "Create an Interval between the receiver and stop by step"
89 ^ Interval from: self to: stop by: step!
93 "Do aBlock from self to stop. Pass the counter to aBlock"
94 self to: stop by: self unity do: aBlock!
97 to: stop reverseDo: aBlock
98 "Do aBlock decreasing self to stop. Pass the counter to aBlock"
99 self to: stop by: self unity reverseDo: aBlock!
102 to: stop by: step do: aBlock
103 "Do aBlock increasing self to stop stepping by step. Pass the counter to aBlock"
109 whileTrue: [ aBlock value: i.
113 whileTrue: [ aBlock value: i.
117 to: stop by: step reverseDo: aBlock
118 "Do aBlock decreasing self to stop stepping by step. Pass the counter to aBlock"
124 whileTrue: [ aBlock value: i.
128 whileTrue: [ aBlock value: i.
136 ^ Fraction numerator: self denominator: 1!
140 ^ self subclassResponsibility!
144 self subclassResponsibility!
148 self subclassResponsibility!
160 ifTrue: [ ^self zero - self ]!
165 ifTrue: [ ^ self negated ]
170 "Answer the reciprocal number of self"
175 "Coerce aNumber and do the sum"
176 ^ self generality > aNumber generality
177 ifTrue: [ self + (self coerce: aNumber) ]
178 ifFalse: [ (aNumber coerce: self) + aNumber ]!
182 "Coerce aNumber and do the difference"
183 ^ self generality > aNumber generality
184 ifTrue: [ self - (self coerce: aNumber) ]
185 ifFalse: [ (aNumber coerce: self) - aNumber ]!
189 "Coerce aNumber and do multiplication"
190 ^ self generality > aNumber generality
191 ifTrue: [ self * (self coerce: aNumber) ]
192 ifFalse: [ (aNumber coerce: self) * aNumber ]!
196 "Coerce aNumber and do division"
198 ifTrue: [ self zeroDivide ].
200 ^ self generality > aNumber generality
201 ifTrue: [ self / (self coerce: aNumber) ]
202 ifFalse: [ (aNumber coerce: self) / aNumber ]!
206 "Do division then answer the quotient floor"
207 ^ (self / aNumber) floor!
211 "Coerce aNumber and do modulo"
212 ^ self generality > aNumber generality
213 ifTrue: [ self \\ (self coerce: aNumber) ]
214 ifFalse: [ (aNumber coerce: self) \\ aNumber ]!
218 "Do division then answer the truncated quotient towards zero"
219 ^ (self / aNumber) truncated!
223 "Do division then answer the truncated remainder towards zero"
224 self notYetImplemented!
231 "Return 1 if self > aNumber, 0 if = aNumber, -1 if < aNumber"
232 self > aNumber ifTrue: [ ^ 1 ].
233 self = aNumber ifTrue: [ ^ 0 ].
234 self < aNumber ifTrue: [ ^ -1 ]!
238 "Coerce aNumber and compare"
239 ^ self generality > aNumber generality
240 ifTrue: [ self < (self coerce: aNumber) ]
241 ifFalse: [ (aNumber coerce: self) < aNumber ]!
245 "Coerce aNumber and compare"
246 ^ self generality > aNumber generality
247 ifTrue: [ self > (self coerce: aNumber) ]
248 ifFalse: [ (aNumber coerce: self) > aNumber ]!
252 "Coerce aNumber and compare"
253 ^ self generality > aNumber generality
254 ifTrue: [ self <= (self coerce: aNumber) ]
255 ifFalse: [ (aNumber coerce: self) <= aNumber ]!
259 "Coerce aNumber and compare"
260 ^ self generality > aNumber generality
261 ifTrue: [ self >= (self coerce: aNumber) ]
262 ifFalse: [ (aNumber coerce: self) >= aNumber ]!
268 "Coerce aNumber and compare equality"
270 ifFalse: [ ^ false ].
271 ^ self generality > aNumber generality
272 ifTrue: [ self = (self coerce: aNumber) ]
273 ifFalse: [ (aNumber coerce: self) = aNumber ]!
277 "Coerce aNumber and compare inequality"
278 ^ self generality > aNumber generality
279 ifTrue: [ self ~= (self coerce: aNumber) ]
280 ifFalse: [ (aNumber coerce: self) ~= aNumber ]!
288 self notYetImplemented!
295 self notYetImplemented!
299 self notYetImplemented!
303 self notYetImplemented!
307 self notYetImplemented!
311 self notYetImplemented!
314 raisedToInteger: anInteger
315 self notYetImplemented!
319 self notYetImplemented!
323 "Answer the square of the receiver"
329 ^ self printStringRadix: 10!