author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 19:02:53 +0200 | |
changeset 1295 | 83f594f05c52 |
parent 1245 | c8afea3d5af0 |
child 1422 | 9a0b792f2953 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
202 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
ArithmeticValue subclass:#Number |
|
973 | 14 |
instanceVariableNames:'' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Magnitude-Numbers' |
|
1 | 18 |
! |
19 |
||
213 | 20 |
!Number class methodsFor:'documentation'! |
88 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
202 | 25 |
All Rights Reserved |
1 | 26 |
|
88 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
1 | 35 |
|
88 | 36 |
documentation |
37 |
" |
|
38 |
abstract superclass for all kinds of numbers |
|
1295 | 39 |
|
40 |
[author:] |
|
41 |
Claus Gittinger |
|
88 | 42 |
" |
43 |
! ! |
|
1 | 44 |
|
45 |
!Number class methodsFor:'instance creation'! |
|
46 |
||
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
47 |
readFrom:aStringOrStream onError:exceptionBlock |
1 | 48 |
"return the next Number from the (character-)stream aStream; |
202 | 49 |
skipping all whitespace first; return the value of exceptionBlock, |
50 |
if no number can be read." |
|
1 | 51 |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
52 |
|str nextChar radix value negative signExp freakOut| |
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
53 |
|
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
54 |
str := aStringOrStream readStream. |
1 | 55 |
|
973 | 56 |
ErrorSignal handle:[:ex | |
57 |
^ exceptionBlock value |
|
339 | 58 |
] do:[ |
973 | 59 |
nextChar := str skipSeparators. |
60 |
nextChar isNil ifTrue:[^ exceptionBlock value]. |
|
3 | 61 |
|
973 | 62 |
freakOut := [^ exceptionBlock value]. |
339 | 63 |
|
973 | 64 |
(nextChar == $-) ifTrue:[ |
65 |
negative := true. |
|
66 |
nextChar := str nextPeek |
|
67 |
] ifFalse:[ |
|
68 |
negative := false. |
|
69 |
(nextChar == $+) ifTrue:[ |
|
70 |
nextChar := str nextPeek |
|
71 |
] |
|
72 |
]. |
|
73 |
nextChar isDigit ifFalse:[ |
|
74 |
^ exceptionBlock value. |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
75 |
"/ value := super readFrom:str. |
339 | 76 |
"/ negative ifTrue:[value := value negated]. |
77 |
"/ ^ value |
|
973 | 78 |
]. |
79 |
value := Integer readFrom:str radix:10 onError:freakOut. |
|
80 |
nextChar := str peek. |
|
81 |
((nextChar == $r) or:[ nextChar == $R]) ifTrue:[ |
|
82 |
str next. |
|
83 |
radix := value. |
|
84 |
value := Integer readFrom:str radix:radix onError:freakOut. |
|
85 |
] ifFalse:[ |
|
86 |
radix := 10 |
|
87 |
]. |
|
88 |
(nextChar == $.) ifTrue:[ |
|
89 |
nextChar := str nextPeek. |
|
90 |
(nextChar notNil and:[nextChar isDigitRadix:radix]) ifTrue:[ |
|
91 |
value := value asFloat |
|
92 |
+ (Number readMantissaFrom:str radix:radix). |
|
93 |
nextChar := str peek |
|
94 |
] |
|
95 |
]. |
|
96 |
((nextChar == $e) or:[nextChar == $E]) ifTrue:[ |
|
97 |
nextChar := str nextPeek. |
|
98 |
signExp := 1. |
|
99 |
(nextChar == $+) ifTrue:[ |
|
100 |
nextChar := str nextPeek |
|
101 |
] ifFalse:[ |
|
102 |
(nextChar == $-) ifTrue:[ |
|
103 |
nextChar := str nextPeek. |
|
104 |
signExp := -1 |
|
105 |
] |
|
106 |
]. |
|
107 |
(nextChar notNil and:[(nextChar isDigitRadix:radix)]) ifTrue:[ |
|
108 |
value := value asFloat |
|
109 |
* (10.0 raisedToInteger: |
|
110 |
((Integer readFrom:str radix:radix onError:freakOut) * signExp)) |
|
111 |
] |
|
112 |
]. |
|
113 |
negative ifTrue:[ |
|
114 |
^ value negated |
|
115 |
]. |
|
116 |
^ value |
|
339 | 117 |
] |
1 | 118 |
|
329 | 119 |
" |
120 |
Number readFrom:(ReadStream on:'54.32e-01') |
|
121 |
Number readFrom:(ReadStream on:'12345678901234567890') |
|
122 |
Number readFrom:(ReadStream on:'16rAAAAFFFFAAAAFFFF') |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
123 |
Number readFrom:'16rAAAAFFFFAAAAFFFF' |
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
124 |
Number readFrom:'0.000001' |
329 | 125 |
'+00000123.45' asNumber |
126 |
" |
|
569
7134eb78cf48
readFrom:onError: can now also read from a string
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
127 |
|
973 | 128 |
"Modified: 20.2.1996 / 20:24:19 / cg" |
296 | 129 |
! |
130 |
||
131 |
readSmalltalkSyntaxFrom:aStream |
|
132 |
"ST-80 compatibility (thanks to a note from alpha testers) |
|
133 |
read and return the next Number in smalltalk syntax from the |
|
329 | 134 |
(character-)stream aStream." |
135 |
||
136 |
^ Compiler evaluate:aStream compile:false "/ self readFrom:aStream. |
|
296 | 137 |
|
329 | 138 |
" |
139 |
Number readSmalltalkSyntaxFrom:(ReadStream on:'54.32e-01') |
|
140 |
Number readSmalltalkSyntaxFrom:(ReadStream on:'12345678901234567890') |
|
141 |
Number readSmalltalkSyntaxFrom:(ReadStream on:'16rAAAAFFFFAAAAFFFF') |
|
142 |
Number readSmalltalkSyntaxFrom:(ReadStream on:'(1/10)') |
|
143 |
Number readFrom:(ReadStream on:'(1/10)') |
|
144 |
Number readSmalltalkSyntaxFrom:(ReadStream on:'+00000123.45') |
|
145 |
Number readFrom:(ReadStream on:'+00000123.45') |
|
146 |
" |
|
1 | 147 |
! ! |
701 | 148 |
|
149 |
!Number class methodsFor:'error reporting'! |
|
150 |
||
151 |
raise:aSignalSymbol receiver:someNumber selector:sel arg:arg errorString:text |
|
152 |
"ST-80 compatible signal raising. Provided for PD numeric classes" |
|
153 |
||
154 |
|msg| |
|
155 |
||
156 |
msg := MessageSend |
|
157 |
receiver:someNumber |
|
158 |
selector:sel |
|
159 |
arguments:(Array with:arg). |
|
160 |
^ (self perform:aSignalSymbol) |
|
161 |
raiseRequestWith:msg |
|
162 |
errorString:text |
|
163 |
in:thisContext sender |
|
164 |
||
165 |
" |
|
166 |
Number raise:#domainErrorSignal |
|
167 |
receiver:1.0 |
|
168 |
selector:#sin |
|
169 |
arg:nil |
|
170 |
errorString:'foo bar test' |
|
171 |
" |
|
172 |
! |
|
173 |
||
174 |
raise:aSignalSymbol receiver:someNumber selector:sel errorString:text |
|
175 |
"ST-80 compatible signal raising. Provided for PD numeric classes" |
|
176 |
||
177 |
|msg| |
|
178 |
||
179 |
msg := MessageSend |
|
180 |
receiver:someNumber |
|
181 |
selector:sel |
|
182 |
arguments:#(). |
|
183 |
^ (self perform:aSignalSymbol) |
|
184 |
raiseRequestWith:msg |
|
185 |
errorString:text |
|
186 |
in:thisContext sender |
|
187 |
||
188 |
" |
|
189 |
Number raise:#domainErrorSignal |
|
190 |
receiver:1.0 |
|
191 |
selector:#foo |
|
192 |
errorString:'foo bar test' |
|
193 |
" |
|
194 |
! ! |
|
195 |
||
196 |
!Number class methodsFor:'private'! |
|
197 |
||
198 |
readMantissaFrom:aStream radix:radix |
|
199 |
"helper for readFrom: - |
|
200 |
return the mantissa from the (character-)stream aStream; |
|
201 |
no whitespace-skipping; error if no number available" |
|
202 |
||
203 |
|nextChar value factor| |
|
204 |
||
205 |
value := 0.0. |
|
206 |
factor := 1.0 / radix. |
|
207 |
nextChar := aStream peek. |
|
208 |
[nextChar notNil and:[nextChar isDigitRadix:radix]] whileTrue:[ |
|
209 |
value := value + (nextChar digitValue * factor). |
|
210 |
factor := factor / radix. |
|
211 |
nextChar := aStream nextPeek |
|
212 |
]. |
|
213 |
^ value |
|
214 |
! ! |
|
215 |
||
216 |
!Number methodsFor:'coercing'! |
|
217 |
||
218 |
coerce:aNumber |
|
219 |
"return aNumber converted into receivers type" |
|
220 |
||
221 |
^ self subclassResponsibility |
|
222 |
! |
|
223 |
||
224 |
generality |
|
225 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
226 |
||
227 |
^ 40 |
|
228 |
! ! |
|
229 |
||
230 |
!Number methodsFor:'converting'! |
|
231 |
||
232 |
@ aNumber |
|
233 |
"return a Point with the receiver as x-coordinate and the argument |
|
234 |
as y-coordinate" |
|
235 |
||
236 |
%{ /* NOCONTEXT */ |
|
237 |
||
238 |
/* |
|
239 |
* I cannot tell if this special code is worth anything |
|
240 |
*/ |
|
835 | 241 |
if (__CanDoQuickNew(sizeof(struct __point))) { |
701 | 242 |
OBJ newPoint; |
243 |
int spc; |
|
244 |
||
835 | 245 |
__qCheckedAlignedNew(newPoint, sizeof(struct __point)); |
1133 | 246 |
__InstPtr(newPoint)->o_class = @global(Point); |
247 |
__PointInstPtr(newPoint)->p_x = self; |
|
248 |
__PointInstPtr(newPoint)->p_y = aNumber; |
|
701 | 249 |
if (! __bothSmallInteger(self, aNumber)) { |
250 |
spc = __qSpace(newPoint); |
|
251 |
__STORE_SPC(newPoint, aNumber, spc); |
|
252 |
__STORE_SPC(newPoint, self, spc); |
|
253 |
} |
|
254 |
RETURN ( newPoint ); |
|
255 |
} |
|
256 |
%} |
|
257 |
. |
|
258 |
^ Point x:self y:aNumber |
|
259 |
! |
|
260 |
||
261 |
asPoint |
|
262 |
"return a new Point with the receiver as all coordinates; |
|
263 |
often used to supply the same value in two dimensions, as with |
|
264 |
symmetrical gridding or scaling." |
|
265 |
||
266 |
%{ /* NOCONTEXT */ |
|
267 |
||
835 | 268 |
if (__CanDoQuickNew(sizeof(struct __point))) { |
701 | 269 |
OBJ newPoint; |
270 |
||
835 | 271 |
__qCheckedAlignedNew(newPoint, sizeof(struct __point)); |
1133 | 272 |
__InstPtr(newPoint)->o_class = @global(Point); |
273 |
__PointInstPtr(newPoint)->p_x = self; |
|
274 |
__PointInstPtr(newPoint)->p_y = self; |
|
701 | 275 |
__STORE(newPoint, self); |
276 |
RETURN ( newPoint ); |
|
277 |
} |
|
278 |
%}. |
|
279 |
^ Point x:self y:self |
|
280 |
! |
|
281 |
||
282 |
degreesToRadians |
|
283 |
"interpreting the receiver as radians, return the degrees" |
|
284 |
||
285 |
^ (self * (Float pi)) / 180.0 |
|
286 |
! |
|
287 |
||
288 |
literalArrayEncoding |
|
1245 | 289 |
"encode myself as an array literal, from which a copy of the receiver |
290 |
can be reconstructed with #decodeAsLiteralArray." |
|
701 | 291 |
|
292 |
^ self |
|
293 |
||
294 |
"Modified: 1.9.1995 / 02:25:26 / claus" |
|
1245 | 295 |
"Modified: 22.4.1996 / 13:00:27 / cg" |
701 | 296 |
! |
297 |
||
298 |
radiansToDegrees |
|
299 |
"interpreting the receiver as degrees, return the radians" |
|
300 |
||
301 |
^ (self * 180.0) / (Float pi) |
|
302 |
! ! |
|
303 |
||
304 |
!Number methodsFor:'intervals'! |
|
305 |
||
306 |
to:stop |
|
307 |
"return an interval from receiver up to the argument, incrementing by 1" |
|
308 |
||
309 |
^ Interval from:self to:stop |
|
310 |
! |
|
311 |
||
312 |
to:stop by:step |
|
313 |
"return an interval from receiver up to the argument, incrementing by step" |
|
314 |
||
315 |
^ Interval from:self to:stop by:step |
|
316 |
! ! |
|
317 |
||
318 |
!Number methodsFor:'iteration'! |
|
319 |
||
320 |
timesRepeat:aBlock |
|
321 |
"evaluate the argument, aBlock self times" |
|
322 |
||
323 |
|count| |
|
324 |
||
325 |
count := self. |
|
326 |
[count > 0] whileTrue:[ |
|
327 |
aBlock value. |
|
328 |
count := count - 1 |
|
329 |
] |
|
330 |
! |
|
331 |
||
332 |
to:stop by:incr do:aBlock |
|
333 |
"For each element of the interval from the receiver up to the argument stop, incrementing |
|
334 |
by step, evaluate aBlock passing the element as argument." |
|
335 |
||
336 |
|tmp| |
|
337 |
||
338 |
tmp := self. |
|
339 |
(incr > 0) ifTrue:[ |
|
340 |
[tmp <= stop] whileTrue:[ |
|
341 |
aBlock value:tmp. |
|
342 |
tmp := tmp+incr |
|
343 |
] |
|
344 |
] ifFalse:[ |
|
345 |
[tmp >= stop] whileTrue:[ |
|
346 |
aBlock value:tmp. |
|
347 |
tmp := tmp+incr |
|
348 |
] |
|
349 |
] |
|
350 |
! |
|
351 |
||
919
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
352 |
to:stop by:incr doWithBreak:aBlock |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
353 |
"For each element of the interval from the receiver up to the argument stop, incrementing |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
354 |
by step, evaluate aBlock passing the element as argument. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
355 |
Pass a break argument, to allow for premature exit of the loop." |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
356 |
|
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
357 |
|tmp break| |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
358 |
|
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
359 |
break := [^ self]. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
360 |
tmp := self. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
361 |
(incr > 0) ifTrue:[ |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
362 |
[tmp <= stop] whileTrue:[ |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
363 |
aBlock value:tmp value:break. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
364 |
tmp := tmp+incr |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
365 |
] |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
366 |
] ifFalse:[ |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
367 |
[tmp >= stop] whileTrue:[ |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
368 |
aBlock value:tmp value:break. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
369 |
tmp := tmp+incr |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
370 |
] |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
371 |
] |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
372 |
|
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
373 |
" |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
374 |
1 to:100 by:5 doWithBreak:[:index :break | |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
375 |
Transcript showCr:index printString. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
376 |
index > 50 ifTrue:[ |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
377 |
break value |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
378 |
]. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
379 |
] |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
380 |
" |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
381 |
! |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
382 |
|
701 | 383 |
to:stop do:aBlock |
384 |
"For each element of the interval from the receiver up to the argument stop, |
|
385 |
evaluate aBlock, passing the number as argument." |
|
386 |
||
387 |
|tmp| |
|
388 |
||
389 |
tmp := self. |
|
390 |
[tmp <= stop] whileTrue:[ |
|
391 |
aBlock value:tmp. |
|
392 |
tmp := tmp+1 |
|
393 |
] |
|
919
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
394 |
! |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
395 |
|
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
396 |
to:stop doWithBreak:aBlock |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
397 |
"For each element of the interval from the receiver up to the argument stop, |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
398 |
evaluate aBlock, passing the number as argument. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
399 |
Pass a break argument, to allow for premature exit of the loop." |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
400 |
|
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
401 |
|tmp break| |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
402 |
|
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
403 |
break := [^ self]. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
404 |
tmp := self. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
405 |
[tmp <= stop] whileTrue:[ |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
406 |
aBlock value:tmp value:break. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
407 |
tmp := tmp+1 |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
408 |
] |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
409 |
|
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
410 |
" |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
411 |
1 to:10 doWithBreak:[:index :break | |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
412 |
Transcript showCr:index printString. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
413 |
index > 5 ifTrue:[ |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
414 |
break value |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
415 |
]. |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
416 |
] |
d285a0816e54
added to:do: loops with break
Claus Gittinger <cg@exept.de>
parents:
835
diff
changeset
|
417 |
" |
701 | 418 |
! ! |
419 |
||
420 |
!Number methodsFor:'printing & storing'! |
|
421 |
||
422 |
storeOn:aStream |
|
423 |
"append a string for storing the receiver onto the argument, |
|
424 |
aStream - since numbers are literals,they store as they print." |
|
425 |
||
426 |
^ self printOn:aStream |
|
427 |
! |
|
428 |
||
429 |
storeString |
|
430 |
"return a string for storing |
|
431 |
- since numbers are literals, they store as they print." |
|
432 |
||
433 |
^ self printString |
|
434 |
! ! |
|
435 |
||
436 |
!Number methodsFor:'testing'! |
|
437 |
||
438 |
isLiteral |
|
439 |
"return true, if the receiver can be used as a literal |
|
440 |
(i.e. can be used in constant arrays)" |
|
441 |
||
442 |
^ true |
|
443 |
! |
|
444 |
||
445 |
isNumber |
|
446 |
"return true, if the receiver is a kind of number" |
|
447 |
||
448 |
^ true |
|
449 |
! |
|
450 |
||
451 |
isZero |
|
452 |
^ self = 0 |
|
453 |
! ! |
|
454 |
||
455 |
!Number class methodsFor:'documentation'! |
|
456 |
||
457 |
version |
|
1295 | 458 |
^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.31 1996-04-25 16:59:17 cg Exp $' |
701 | 459 |
! ! |