author | Claus Gittinger <cg@exept.de> |
Wed, 28 Oct 1998 17:18:22 +0100 | |
changeset 3898 | 818a12afad05 |
parent 3732 | bf041aa09cc4 |
child 4455 | 2d31d0d986be |
permissions | -rw-r--r-- |
55 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
213 | 3 |
All Rights Reserved |
55 | 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 |
Number subclass:#LimitedPrecisionReal |
|
1200 | 14 |
instanceVariableNames:'' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Magnitude-Numbers' |
|
55 | 18 |
! |
19 |
||
88 | 20 |
!LimitedPrecisionReal class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
213 | 25 |
All Rights Reserved |
55 | 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 |
! |
|
55 | 35 |
|
88 | 36 |
documentation |
37 |
" |
|
38 |
Abstract superclass for single and double (and maybe more) |
|
39 |
precision real numbers (i.e. Float and Double). |
|
92 | 40 |
|
41 |
Due to historic reasons, ST/X's Floats are what Doubles are in ST-80. |
|
42 |
This may change soon (implementing LPReal is a first step towards this). |
|
1295 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
1893 | 46 |
|
47 |
[see also:] |
|
48 |
Fraction FixedPoint |
|
88 | 49 |
" |
50 |
! ! |
|
55 | 51 |
|
52 |
!LimitedPrecisionReal class methodsFor:'instance creation'! |
|
53 |
||
54 |
new:aNumber |
|
55 |
"catch this message - not allowed for floats/doubles" |
|
56 |
||
57 |
self error:'Floats/Doubles cannot be created with new:' |
|
58 |
! ! |
|
59 |
||
60 |
!LimitedPrecisionReal methodsFor:'accessing'! |
|
61 |
||
62 |
at:index |
|
63 |
"redefined to prevent access to individual bytes in a real." |
|
64 |
||
65 |
self error:'not allowed for floats/doubles' |
|
66 |
! |
|
67 |
||
68 |
at:index put:aValue |
|
69 |
"redefined to prevent access to individual bytes in a real" |
|
70 |
||
71 |
self error:'not allowed for floats/doubles' |
|
701 | 72 |
! |
73 |
||
74 |
size |
|
75 |
"redefined since reals are kludgy (ByteArry)" |
|
76 |
||
77 |
^ 0 |
|
55 | 78 |
! ! |
79 |
||
80 |
!LimitedPrecisionReal methodsFor:'arithmetic'! |
|
81 |
||
701 | 82 |
* aNumber |
83 |
"return the product of the receiver and the argument, aNumber" |
|
84 |
||
1200 | 85 |
"/ as soon as Float are float & Double are doubles, |
86 |
"/ use: |
|
87 |
"/ ^ aNumber productFromDouble:self asDouble |
|
88 |
||
89 |
^ aNumber productFromFloat:self asFloat |
|
90 |
||
91 |
"Modified: 17.4.1996 / 12:35:36 / cg" |
|
701 | 92 |
! |
93 |
||
55 | 94 |
+ aNumber |
95 |
"return the sum of the receiver and the argument, aNumber" |
|
96 |
||
1200 | 97 |
"/ as soon as Float are float & Double are doubles, |
98 |
"/ use: |
|
99 |
"/ ^ aNumber sumFromDouble:self asDouble |
|
100 |
||
101 |
^ aNumber sumFromFloat:self asFloat |
|
102 |
||
103 |
"Modified: 17.4.1996 / 12:35:55 / cg" |
|
55 | 104 |
! |
105 |
||
106 |
- aNumber |
|
107 |
"return the difference of the receiver and the argument, aNumber" |
|
108 |
||
1200 | 109 |
"/ as soon as Float are float & Double are doubles, |
110 |
"/ use: |
|
111 |
"/ ^ aNumber differenceFromDouble:self asDouble |
|
112 |
||
113 |
^ aNumber differenceFromFloat:self asFloat |
|
114 |
||
115 |
"Modified: 17.4.1996 / 12:36:07 / cg" |
|
55 | 116 |
! |
117 |
||
118 |
/ aNumber |
|
119 |
"return the quotient of the receiver and the argument, aNumber" |
|
120 |
||
121 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
|
1200 | 122 |
^ DivisionByZeroSignal raise. |
55 | 123 |
]. |
1200 | 124 |
"/ as soon as Float are float & Double are doubles, |
125 |
"/ use: |
|
126 |
"/ ^ aNumber quotientFromDouble:self asDouble |
|
127 |
||
128 |
^ aNumber quotientFromFloat:self asFloat |
|
129 |
||
130 |
"Modified: 17.4.1996 / 12:36:21 / cg" |
|
55 | 131 |
! |
132 |
||
133 |
// aNumber |
|
134 |
"return the integer quotient of dividing the receiver by aNumber with |
|
1882 | 135 |
truncation towards negative infinity." |
55 | 136 |
|
137 |
^ (self / aNumber) floor asInteger |
|
1882 | 138 |
|
139 |
"Modified: 5.11.1996 / 11:45:37 / cg" |
|
55 | 140 |
! ! |
141 |
||
142 |
!LimitedPrecisionReal methodsFor:'coercion and converting'! |
|
143 |
||
2141 | 144 |
asFixedPoint |
145 |
"return the receiver as fixedPoint number. |
|
146 |
Q: what should the scale be here ?" |
|
147 |
||
148 |
^ self asFraction asFixedPoint |
|
149 |
||
150 |
" |
|
151 |
0.3 asFixedPoint |
|
152 |
0.5 asFixedPoint |
|
153 |
(1/5) asFloat asFixedPoint |
|
154 |
(1/3) asFloat asFixedPoint |
|
155 |
(2/3) asFloat asFixedPoint |
|
156 |
(1/8) asFloat asFixedPoint |
|
157 |
3.14159 asFixedPoint |
|
3060 | 158 |
0.0000001 asFraction |
159 |
0.0000001 asFixedPoint |
|
2141 | 160 |
" |
161 |
||
3060 | 162 |
"Modified: / 25.10.1997 / 15:36:54 / cg" |
2141 | 163 |
! |
164 |
||
165 |
asFixedPoint:scale |
|
166 |
"return the receiver as fixedPoint number with the given |
|
167 |
number of post-decimal-digits." |
|
168 |
||
169 |
^ self asFraction asFixedPoint:scale |
|
170 |
||
171 |
" |
|
3732 | 172 |
0.3 asFixedPoint:4 |
2141 | 173 |
0.3 asFixedPoint:3 |
3732 | 174 |
0.3 asFixedPoint:2 |
175 |
0.3 asFixedPoint:1 |
|
176 |
0.3 asFixedPoint:0 |
|
177 |
||
2141 | 178 |
0.5 asFixedPoint:3 |
179 |
(1/5) asFloat asFixedPoint:1 |
|
180 |
(1/8) asFloat asFixedPoint:1 |
|
181 |
3.14159 asFixedPoint:2 |
|
182 |
3.14159 asFixedPoint:3 |
|
183 |
(3.14159 asFixedPoint:2) asFixedPoint:5 |
|
184 |
" |
|
185 |
||
3732 | 186 |
"Modified: / 5.8.1998 / 13:29:51 / cg" |
2141 | 187 |
! |
188 |
||
55 | 189 |
asFraction |
3060 | 190 |
"return a corresponding fraction or integer |
191 |
(fractions with 1 as denominator are not allowed/useful) |
|
55 | 192 |
- notice, that 'aFract asFloat asFraction' does not always return |
193 |
a good fraction ... due to rounding errors when converting to float" |
|
194 |
||
3060 | 195 |
|fract digits power num denom eI| |
55 | 196 |
|
197 |
"we (indirectly) use printf which knows the precision of floats" |
|
198 |
||
199 |
fract := self fractionPart. |
|
3060 | 200 |
fract = 0.0 ifTrue:[ |
201 |
^ self asInteger. |
|
202 |
]. |
|
203 |
||
204 |
"/ use printf, so we dont need to know anything |
|
205 |
"/ about float representation here. |
|
206 |
||
207 |
digits := (fract printfPrintString:'%.16f'). |
|
208 |
eI := digits size. |
|
209 |
[(digits at:eI) == $0] whileTrue:[ |
|
210 |
eI := eI - 1 |
|
211 |
]. |
|
212 |
||
213 |
power := eI - 3 + 1. |
|
55 | 214 |
num := (self - fract) asInteger. |
215 |
denom := (10 raisedToInteger:power). |
|
216 |
num := num * denom. |
|
3060 | 217 |
num := num + (fract * denom) asInteger. |
218 |
||
2793 | 219 |
^ Fraction numerator:num denominator:denom |
55 | 220 |
|
3060 | 221 |
" |
222 |
0.3 asFraction |
|
223 |
0.5 asFraction |
|
224 |
(1/5) asFloat asFraction |
|
225 |
(1/8) asFloat asFraction |
|
226 |
(1/13) asFloat asFraction |
|
227 |
3.14159 asFraction |
|
228 |
1.3 asFraction |
|
229 |
1.0 asFraction |
|
230 |
" |
|
2793 | 231 |
|
3060 | 232 |
"Modified: / 25.10.1997 / 16:41:19 / cg" |
55 | 233 |
! |
234 |
||
235 |
asInteger |
|
236 |
"return an integer with same value - might truncate" |
|
237 |
||
3185 | 238 |
|max maxF| |
55 | 239 |
|
2388 | 240 |
self isNaN ifTrue:[ |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
241 |
^ self class |
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
242 |
raise:#domainErrorSignal |
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
243 |
receiver:self |
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
244 |
selector:#asInteger |
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
245 |
errorString:'receiver is NaN in #asInteger' |
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
246 |
|
2388 | 247 |
]. |
248 |
||
3426 | 249 |
"/ NOTICE: this must be redefined in float |
250 |
"/ subclasses to handle the smallinteger range; |
|
251 |
"/ i.e. this may only be invoked for reals |
|
252 |
"/ which are NOT within the smallInt range. |
|
253 |
"/ otherwise, endless recursion is the consequence. |
|
254 |
||
3137 | 255 |
max := SmallInteger maxVal // 2 + 1. |
256 |
maxF := max asFloat. |
|
3426 | 257 |
|
3137 | 258 |
^ (self quo:maxF) * max + (self rem:maxF) truncated |
55 | 259 |
|
3137 | 260 |
" |
261 |
12345.0 asInteger |
|
262 |
1e15 asInteger |
|
263 |
1e33 asInteger |
|
264 |
" |
|
2388 | 265 |
|
266 |
"Modified: 12.2.1997 / 16:45:07 / cg" |
|
701 | 267 |
! |
268 |
||
269 |
coerce:aNumber |
|
270 |
"return aNumber converted into receivers type" |
|
271 |
||
1200 | 272 |
"/ as soon as Float are float & Double are doubles, |
273 |
"/ use: |
|
274 |
"/ ^ aNumber asDouble |
|
275 |
||
276 |
^ aNumber asFloat |
|
277 |
||
278 |
"Modified: 17.4.1996 / 12:36:46 / cg" |
|
701 | 279 |
! |
280 |
||
3898 | 281 |
fractionalPart |
282 |
"This has been renamed to #fractionPart for ST80 compatibility. |
|
283 |
||
284 |
extract the after-decimal fraction part. |
|
285 |
the floats value is |
|
286 |
float truncated + float fractionalPart" |
|
287 |
||
288 |
self obsoleteMethodWarning:'please use #fractionPart'. |
|
289 |
^ self fractionPart |
|
290 |
||
291 |
"Modified: / 28.10.1998 / 17:10:12 / cg" |
|
292 |
"Created: / 28.10.1998 / 17:10:32 / cg" |
|
293 |
! |
|
294 |
||
701 | 295 |
generality |
296 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
297 |
||
298 |
^ 80 |
|
299 |
! ! |
|
300 |
||
301 |
!LimitedPrecisionReal methodsFor:'comparing'! |
|
302 |
||
303 |
< aNumber |
|
304 |
"return true, if the argument is greater" |
|
305 |
||
1201
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
306 |
"/ as soon as Float are float & Double are doubles, |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
307 |
"/ use: |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
308 |
"/ ^ aNumber lessFromDouble:self asDouble |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
309 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
310 |
^ aNumber lessFromFloat:self asFloat |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
311 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
312 |
"Modified: 17.4.1996 / 13:34:50 / cg" |
701 | 313 |
! |
314 |
||
315 |
<= aNumber |
|
316 |
"return true, if the argument is greater or equal" |
|
317 |
||
318 |
^ self retry:#<= coercing:aNumber |
|
319 |
! |
|
320 |
||
321 |
= aNumber |
|
322 |
"return true, if the arguments value are equal" |
|
323 |
||
324 |
^ self retry:#= coercing:aNumber |
|
325 |
! |
|
326 |
||
327 |
> aNumber |
|
328 |
"return true, if the argument is less" |
|
329 |
||
330 |
^ self retry:#> coercing:aNumber |
|
331 |
! |
|
332 |
||
333 |
>= aNumber |
|
334 |
"return true, if the argument is less or equal" |
|
335 |
||
336 |
^ self retry:#>= coercing:aNumber |
|
337 |
! |
|
338 |
||
339 |
~= aNumber |
|
340 |
"return true, if the arguments value are not equal" |
|
341 |
||
342 |
^ self retry:#~= coercing:aNumber |
|
343 |
! ! |
|
344 |
||
345 |
!LimitedPrecisionReal methodsFor:'copying'! |
|
346 |
||
347 |
deepCopy |
|
348 |
"return a deep copy of myself |
|
349 |
- because storing into floats is not recommended/allowed, its ok to return the receiver" |
|
350 |
||
351 |
^ self |
|
352 |
! |
|
353 |
||
354 |
deepCopyUsing:aDictionary |
|
355 |
"return a deep copy of myself |
|
356 |
- because storing into floats is not recommended/allowed, its ok to return the receiver" |
|
357 |
||
358 |
^ self |
|
359 |
! |
|
360 |
||
361 |
shallowCopy |
|
362 |
"return a shallow copy of the receiver" |
|
363 |
||
364 |
^ self |
|
365 |
! |
|
366 |
||
367 |
simpleDeepCopy |
|
368 |
"return a deep copy of the receiver |
|
369 |
- because storing into floats is not recommended/allowed, its ok to return the receiver" |
|
370 |
||
371 |
^ self |
|
55 | 372 |
! ! |
373 |
||
374 |
!LimitedPrecisionReal methodsFor:'double dispatching'! |
|
375 |
||
376 |
differenceFromFraction:aFraction |
|
213 | 377 |
"sent when a fraction does not know how to subtract the receiver, a float" |
55 | 378 |
|
379 |
|d| |
|
380 |
||
381 |
d := aFraction denominator. |
|
382 |
^ (aFraction numerator - (self * d)) / d |
|
383 |
! |
|
384 |
||
385 |
productFromFraction:aFraction |
|
213 | 386 |
"sent when a fraction does not know how to multiply the receiver, a float" |
55 | 387 |
|
388 |
^ self * aFraction numerator / aFraction denominator |
|
389 |
! |
|
390 |
||
391 |
quotientFromFraction:aFraction |
|
213 | 392 |
"sent when a fraction does not know how to divide by the receiver, a float" |
55 | 393 |
|
394 |
^ aFraction numerator / (self * aFraction denominator) |
|
701 | 395 |
! |
396 |
||
397 |
sumFromFraction:aFraction |
|
398 |
"sent when a fraction does not know how to add the receiver, a float" |
|
399 |
||
400 |
|d| |
|
401 |
||
402 |
d := aFraction denominator. |
|
403 |
^ (self * d + aFraction numerator) / d |
|
404 |
! ! |
|
405 |
||
406 |
!LimitedPrecisionReal methodsFor:'printing & storing'! |
|
407 |
||
408 |
printOn:aStream |
|
409 |
"append a printed representation of the receiver to |
|
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
410 |
the argument, aStream. |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
411 |
|
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
412 |
LimitedPrecisonReal and its subclasses use #printString instead of |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
413 |
#printOn: as basic print mechanism." |
701 | 414 |
|
415 |
aStream nextPutAll:self printString |
|
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
416 |
|
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
417 |
"Modified: / 20.1.1998 / 14:10:46 / stefan" |
1200 | 418 |
! |
419 |
||
420 |
printString |
|
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
421 |
"return a printed representation of the receiver |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
422 |
LimitedPrecisonReal and its subclasses use #printString instead of |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
423 |
#printOn: as basic print mechanism." |
1200 | 424 |
|
425 |
^ self subclassResponsibility |
|
426 |
||
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
427 |
"Created: / 17.4.1996 / 12:12:20 / cg" |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
428 |
"Modified: / 20.1.1998 / 14:10:47 / stefan" |
701 | 429 |
! ! |
430 |
||
431 |
!LimitedPrecisionReal methodsFor:'testing'! |
|
432 |
||
3148
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
433 |
isFinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
434 |
^ self subclassResponsibility |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
435 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
436 |
"Created: / 7.1.1998 / 12:02:06 / stefan" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
437 |
! |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
438 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
439 |
isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
440 |
"return true, if the receiver is an infinite float (Inf). |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
441 |
These are not created by ST/X float operations (they raise an exception); |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
442 |
however, inline C-code could produce them ..." |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
443 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
444 |
^ (self isFinite or:[self isNaN]) not. |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
445 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
446 |
" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
447 |
1.0 isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
448 |
(0.0 uncheckedDivide: 0.0) isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
449 |
(1.0 uncheckedDivide: 0.0) isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
450 |
" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
451 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
452 |
"Modified: / 7.1.1998 / 12:01:30 / stefan" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
453 |
! |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
454 |
|
2388 | 455 |
isNaN |
456 |
^ self subclassResponsibility |
|
457 |
||
458 |
"Modified: 12.2.1997 / 16:45:27 / cg" |
|
459 |
! |
|
460 |
||
701 | 461 |
isReal |
462 |
"return true, if the receiver is some kind of real number; |
|
463 |
false is returned here - the method is redefined from Object." |
|
464 |
||
465 |
^ true |
|
466 |
! |
|
467 |
||
468 |
negative |
|
469 |
"return true if the receiver is less than zero" |
|
470 |
||
1201
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
471 |
"/ as soon as Float are float & Double are doubles, |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
472 |
"/ use: |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
473 |
"/ ^ self asDouble negative |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
474 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
475 |
^ self asFloat negative |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
476 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
477 |
"Modified: 17.4.1996 / 13:35:00 / cg" |
701 | 478 |
! |
479 |
||
480 |
positive |
|
481 |
"return true if the receiver is greater or equal to zero" |
|
482 |
||
1201
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
483 |
"/ as soon as Float are float & Double are doubles, |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
484 |
"/ use: |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
485 |
"/ ^ self asDouble positive |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
486 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
487 |
^ self asFloat positive |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
488 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
489 |
"Modified: 17.4.1996 / 13:35:10 / cg" |
55 | 490 |
! ! |
491 |
||
701 | 492 |
!LimitedPrecisionReal class methodsFor:'documentation'! |
55 | 493 |
|
701 | 494 |
version |
3898 | 495 |
^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.30 1998-10-28 16:18:22 cg Exp $' |
55 | 496 |
! ! |