author | Claus Gittinger <cg@exept.de> |
Wed, 12 Feb 1997 16:49:38 +0100 | |
changeset 2387 | 3aafb49a86ac |
parent 1893 | c66af5c46272 |
child 2389 | 37b5964a9308 |
permissions | -rw-r--r-- |
1197 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
||
14 |
||
15 |
LimitedPrecisionReal variableByteSubclass:#ShortFloat |
|
16 |
instanceVariableNames:'' |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
17 |
classVariableNames:'' |
1197 | 18 |
poolDictionaries:'' |
19 |
category:'Magnitude-Numbers' |
|
20 |
! |
|
21 |
||
1880 | 22 |
!ShortFloat class methodsFor:'documentation'! |
1197 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
ShortFloats represent rational numbers with limited precision. In ST/X, Float uses |
|
43 |
the underlying C-compilers double implementation, while ShortFloats are |
|
44 |
mapped onto C-floats. |
|
45 |
Therefore instances of Float are usually represented by the 8-byte IEE |
|
46 |
double precision float format, while ShortFloats use 4byte IEE format. |
|
47 |
(but there is no guaranty). |
|
48 |
||
49 |
Notice, that ST/X Floats are what Doubles are in ST-80 and ShortFloats are |
|
50 |
ST-80's Floats respectively. |
|
51 |
This may change in one of the next versions (at least on machines, which |
|
52 |
provide different float and double types in their C-compiler. |
|
53 |
||
54 |
WARNING: |
|
55 |
The layout of shortFloat instances is known by the runtime system and the compiler; |
|
56 |
you may not add instance variables here. |
|
57 |
Also, subclassing is complicated by the fact, that the VM creates floats/shortFloats, |
|
58 |
and does its float-checks by an identity compare with the ShortFloat-class. |
|
59 |
(i.e. your subclasses instances may not be recognized as float-like objects, |
|
60 |
thus mixed mode arithmetic will always coerce them, effectively slowing things down). |
|
61 |
||
62 |
This may be changed, to use a flag bit in the class. |
|
1295 | 63 |
|
64 |
[author:] |
|
65 |
Claus Gittinger |
|
1556 | 66 |
|
67 |
[see also:] |
|
68 |
Number |
|
1893 | 69 |
Float Fraction FixedPoint Integer |
1197 | 70 |
" |
71 |
||
72 |
! ! |
|
73 |
||
1880 | 74 |
!ShortFloat class methodsFor:'instance creation'! |
1207 | 75 |
|
76 |
basicNew |
|
77 |
"return a new shortFloat - here we return 0.0 |
|
78 |
- shortFloats are usually NOT created this way ... |
|
79 |
Its implemented here to allow things like binary store & load |
|
80 |
of shortFloats. (but even this support will go away eventually, its not |
|
81 |
a good idea to store the bits of a float - the reader might have a |
|
82 |
totally different representation - so floats will eventually be |
|
83 |
binary stored in a device independent format." |
|
84 |
||
85 |
%{ /* NOCONTEXT */ |
|
86 |
OBJ newFloat; |
|
87 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
88 |
__qMKSFLOAT(newFloat, 0.0); |
1207 | 89 |
RETURN (newFloat); |
90 |
%} |
|
91 |
! ! |
|
92 |
||
1880 | 93 |
!ShortFloat class methodsFor:'constants'! |
1197 | 94 |
|
95 |
pi |
|
1260 | 96 |
"return the constant pi as ShortFloat" |
1197 | 97 |
|
98 |
^ 3.14159 asShortFloat |
|
99 |
||
1260 | 100 |
"Modified: 23.4.1996 / 09:26:31 / cg" |
1197 | 101 |
! |
102 |
||
103 |
unity |
|
1260 | 104 |
"return the neutral element for multiplication (1.0) as ShortFloat" |
1197 | 105 |
|
106 |
^ 1.0 asShortFloat |
|
107 |
||
1260 | 108 |
"Modified: 23.4.1996 / 09:26:51 / cg" |
1197 | 109 |
! |
110 |
||
111 |
zero |
|
1260 | 112 |
"return the neutral element for addition (0.0) as ShortFloat" |
1197 | 113 |
|
114 |
^ 0.0 asShortFloat |
|
115 |
||
1260 | 116 |
"Modified: 23.4.1996 / 09:26:45 / cg" |
1197 | 117 |
! ! |
118 |
||
1880 | 119 |
!ShortFloat class methodsFor:'queries'! |
1197 | 120 |
|
121 |
isBuiltInClass |
|
1264 | 122 |
"return true if this class is known by the run-time-system. |
123 |
Here, true is returned for myself, false for subclasses." |
|
1197 | 124 |
|
125 |
^ self == ShortFloat |
|
126 |
||
1264 | 127 |
"Modified: 23.4.1996 / 16:00:23 / cg" |
1197 | 128 |
! ! |
129 |
||
130 |
!ShortFloat methodsFor:'arithmetic'! |
|
131 |
||
132 |
* aNumber |
|
133 |
"return the product of the receiver and the argument, aNumber" |
|
134 |
||
135 |
%{ /* NOCONTEXT */ |
|
136 |
||
137 |
OBJ newFloat; |
|
138 |
float result; |
|
139 |
double dResult; |
|
140 |
||
141 |
if (__isSmallInteger(aNumber)) { |
|
142 |
result = __shortFloatVal(self) * (float)(__intVal(aNumber)); |
|
143 |
retResult: |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
144 |
__qMKSFLOAT(newFloat, result); |
1197 | 145 |
RETURN ( newFloat ); |
146 |
} |
|
147 |
if (__isShortFloat(aNumber)) { |
|
148 |
result = __shortFloatVal(self) * __shortFloatVal(aNumber); |
|
149 |
goto retResult; |
|
150 |
} |
|
151 |
if (__isFloatLike(aNumber)) { |
|
152 |
dResult = (double) __shortFloatVal(self)* __floatVal(aNumber); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
153 |
__qMKFLOAT(newFloat, dResult); |
1197 | 154 |
RETURN ( newFloat ); |
155 |
||
156 |
} |
|
157 |
%}. |
|
158 |
^ aNumber productFromShortFloat:self |
|
159 |
! |
|
160 |
||
161 |
+ aNumber |
|
162 |
"return the sum of the receiver and the argument, aNumber" |
|
163 |
||
164 |
%{ /* NOCONTEXT */ |
|
165 |
||
166 |
OBJ newFloat; |
|
167 |
float result; |
|
168 |
double dResult; |
|
169 |
||
170 |
if (__isSmallInteger(aNumber)) { |
|
171 |
result = __shortFloatVal(self) + (float)(__intVal(aNumber)); |
|
172 |
retResult: |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
173 |
__qMKSFLOAT(newFloat, result); |
1197 | 174 |
RETURN ( newFloat ); |
175 |
} |
|
176 |
if (__isShortFloat(aNumber)) { |
|
177 |
result = __shortFloatVal(self) + __shortFloatVal(aNumber); |
|
178 |
goto retResult; |
|
179 |
} |
|
180 |
if (__isFloatLike(aNumber)) { |
|
181 |
dResult = (double) __shortFloatVal(self) + __floatVal(aNumber); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
182 |
__qMKFLOAT(newFloat, dResult); |
1197 | 183 |
RETURN ( newFloat ); |
184 |
||
185 |
} |
|
186 |
%}. |
|
187 |
^ aNumber sumFromShortFloat:self |
|
188 |
! |
|
189 |
||
190 |
- aNumber |
|
191 |
"return the difference of the receiver and the argument, aNumber" |
|
192 |
||
193 |
%{ /* NOCONTEXT */ |
|
194 |
||
195 |
OBJ newFloat; |
|
196 |
float result; |
|
197 |
double dResult; |
|
198 |
||
199 |
if (__isSmallInteger(aNumber)) { |
|
200 |
result = __shortFloatVal(self) - (float)(__intVal(aNumber)); |
|
201 |
retResult: |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
202 |
__qMKSFLOAT(newFloat, result); |
1197 | 203 |
RETURN ( newFloat ); |
204 |
} |
|
205 |
if (__isShortFloat(aNumber)) { |
|
206 |
result = __shortFloatVal(self) - __shortFloatVal(aNumber); |
|
207 |
goto retResult; |
|
208 |
} |
|
209 |
if (__isFloatLike(aNumber)) { |
|
210 |
dResult = (double) __shortFloatVal(self) - __floatVal(aNumber); |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
211 |
__qMKFLOAT(newFloat, dResult); |
1197 | 212 |
RETURN ( newFloat ); |
213 |
||
214 |
} |
|
215 |
%}. |
|
216 |
^ aNumber differenceFromShortFloat:self |
|
217 |
! |
|
218 |
||
219 |
/ aNumber |
|
220 |
"return the quotient of the receiver and the argument, aNumber" |
|
221 |
||
222 |
%{ /* NOCONTEXT */ |
|
223 |
||
224 |
OBJ newFloat; |
|
225 |
float result, val; |
|
226 |
double dResult, dVal; |
|
227 |
||
228 |
if (__isSmallInteger(aNumber)) { |
|
229 |
if (aNumber != __MKSMALLINT(0)) { |
|
230 |
result = __shortFloatVal(self) / (float)(__intVal(aNumber)); |
|
231 |
retResult: |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
232 |
__qMKSFLOAT(newFloat, result); |
1197 | 233 |
RETURN ( newFloat ); |
234 |
} |
|
235 |
} |
|
236 |
if (__isShortFloat(aNumber)) { |
|
237 |
val = __shortFloatVal(aNumber); |
|
238 |
if (val != 0.0) { |
|
239 |
result = __shortFloatVal(self) / val; |
|
240 |
goto retResult; |
|
241 |
} |
|
242 |
} |
|
243 |
if (__isFloatLike(aNumber)) { |
|
244 |
dVal = __floatVal(aNumber); |
|
245 |
if (dVal != 0.0) { |
|
246 |
dResult = (double) __shortFloatVal(self) / dVal; |
|
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
247 |
__qMKFLOAT(newFloat, dResult); |
1197 | 248 |
} |
249 |
RETURN ( newFloat ); |
|
250 |
||
251 |
} |
|
252 |
%}. |
|
253 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
|
254 |
" |
|
255 |
No, you shalt not divide by zero |
|
256 |
" |
|
257 |
^ DivisionByZeroSignal raise. |
|
258 |
]. |
|
259 |
^ aNumber quotientFromFloat:self |
|
260 |
||
261 |
! |
|
262 |
||
263 |
negated |
|
264 |
"return myself negated" |
|
265 |
||
266 |
%{ /* NOCONTEXT */ |
|
267 |
OBJ newFloat; |
|
268 |
float rslt = - __shortFloatVal(self); |
|
269 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
270 |
__qMKSFLOAT(newFloat, rslt); |
1197 | 271 |
RETURN ( newFloat ); |
272 |
%} |
|
273 |
||
274 |
! ! |
|
275 |
||
276 |
!ShortFloat methodsFor:'coercion and converting'! |
|
277 |
||
278 |
asFloat |
|
279 |
"return a Float with same value as the receiver" |
|
280 |
||
281 |
%{ /* NOCONTEXT */ |
|
282 |
||
283 |
OBJ newFloat; |
|
284 |
double dVal = (double)__shortFloatVal(self); |
|
285 |
||
1695
465e1eba8e8e
removed useless context-arg of all qMK macros - needs full recompile.
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
286 |
__qMKFLOAT(newFloat, dVal); |
1197 | 287 |
RETURN ( newFloat ); |
288 |
%} |
|
289 |
||
290 |
" |
|
1583 | 291 |
1.0 asShortFloat asFloat |
1197 | 292 |
" |
293 |
! |
|
294 |
||
295 |
asInteger |
|
296 |
"return an integer with same value - might truncate" |
|
297 |
||
298 |
%{ /* NOCONTEXT */ |
|
1670 | 299 |
float fVal; |
1197 | 300 |
|
1670 | 301 |
fVal = __shortFloatVal(self); |
302 |
if ((fVal >= (float)_MIN_INT) && (fVal <= (float)_MAX_INT)) { |
|
303 |
RETURN ( __MKSMALLINT( (INT)fVal) ); |
|
1197 | 304 |
} |
305 |
%}. |
|
306 |
^ super asInteger |
|
307 |
||
308 |
" |
|
309 |
12345.0 asShortFloat asInteger |
|
310 |
1e15 asShortFloat asInteger |
|
311 |
" |
|
312 |
! |
|
313 |
||
314 |
asShortFloat |
|
315 |
"return a ShortFloat with same value as the receiver - thats me" |
|
316 |
||
317 |
^ self |
|
1200 | 318 |
! |
319 |
||
320 |
generality |
|
321 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
322 |
||
323 |
^ 70 |
|
324 |
||
325 |
||
1197 | 326 |
! ! |
327 |
||
328 |
!ShortFloat methodsFor:'comparing'! |
|
329 |
||
330 |
< aNumber |
|
331 |
"return true, if the argument is greater" |
|
332 |
||
333 |
%{ /* NOCONTEXT */ |
|
334 |
||
335 |
if (__isSmallInteger(aNumber)) { |
|
336 |
RETURN ( (__shortFloatVal(self) < (float)(__intVal(aNumber))) ? true : false ); |
|
337 |
} |
|
338 |
if (__isFloatLike(aNumber)) { |
|
339 |
RETURN ( (double)(__shortFloatVal(self) < __floatVal(aNumber)) ? true : false ); |
|
340 |
} |
|
341 |
if (__isShortFloat(aNumber)) { |
|
342 |
RETURN ( (__shortFloatVal(self) < __shortFloatVal(aNumber)) ? true : false ); |
|
343 |
} |
|
344 |
%}. |
|
345 |
^ aNumber lessFromShortFloat:self |
|
346 |
||
1200 | 347 |
" |
348 |
1.0 asShortFloat > (1/3) |
|
349 |
" |
|
1197 | 350 |
! |
351 |
||
352 |
<= aNumber |
|
353 |
"return true, if the argument is greater or equal" |
|
354 |
||
355 |
%{ /* NOCONTEXT */ |
|
356 |
||
357 |
if (__isSmallInteger(aNumber)) { |
|
358 |
RETURN ( (__shortFloatVal(self) <= (float)(__intVal(aNumber))) ? true : false ); |
|
359 |
} |
|
360 |
if (__isFloatLike(aNumber)) { |
|
361 |
RETURN ( (double)(__shortFloatVal(self) <= __floatVal(aNumber)) ? true : false ); |
|
362 |
} |
|
363 |
if (__isShortFloat(aNumber)) { |
|
364 |
RETURN ( (__shortFloatVal(self) <= __shortFloatVal(aNumber)) ? true : false ); |
|
365 |
} |
|
366 |
%}. |
|
367 |
^ self retry:#<= coercing:aNumber |
|
368 |
||
369 |
! |
|
370 |
||
371 |
= aNumber |
|
372 |
"return true, if the arguments value are equal by value" |
|
373 |
||
374 |
%{ /* NOCONTEXT */ |
|
375 |
||
376 |
if (__isSmallInteger(aNumber)) { |
|
377 |
RETURN ( (__shortFloatVal(self) == (float)(__intVal(aNumber))) ? true : false ); |
|
378 |
} |
|
379 |
if (__isFloatLike(aNumber)) { |
|
380 |
RETURN ( (double)(__shortFloatVal(self) == __floatVal(aNumber)) ? true : false ); |
|
381 |
} |
|
382 |
if (__isShortFloat(aNumber)) { |
|
383 |
RETURN ( (__shortFloatVal(self) == __shortFloatVal(aNumber)) ? true : false ); |
|
384 |
} |
|
385 |
%}. |
|
386 |
^ self retry:#= coercing:aNumber |
|
387 |
||
388 |
! |
|
389 |
||
390 |
> aNumber |
|
391 |
"return true, if the argument is less" |
|
392 |
||
393 |
%{ /* NOCONTEXT */ |
|
394 |
||
395 |
if (__isSmallInteger(aNumber)) { |
|
396 |
RETURN ( (__shortFloatVal(self) > (float)(__intVal(aNumber))) ? true : false ); |
|
397 |
} |
|
398 |
if (__isFloatLike(aNumber)) { |
|
399 |
RETURN ( (double)(__shortFloatVal(self) > __floatVal(aNumber)) ? true : false ); |
|
400 |
} |
|
401 |
if (__isShortFloat(aNumber)) { |
|
402 |
RETURN ( (__shortFloatVal(self) > __shortFloatVal(aNumber)) ? true : false ); |
|
403 |
} |
|
404 |
%}. |
|
405 |
^ self retry:#> coercing:aNumber |
|
406 |
! |
|
407 |
||
408 |
>= aNumber |
|
409 |
"return true, if the argument is less or equal" |
|
410 |
||
411 |
%{ /* NOCONTEXT */ |
|
412 |
||
413 |
if (__isSmallInteger(aNumber)) { |
|
414 |
RETURN ( (__shortFloatVal(self) >= (float)(__intVal(aNumber))) ? true : false ); |
|
415 |
} |
|
416 |
if (__isFloatLike(aNumber)) { |
|
417 |
RETURN ( (double)(__shortFloatVal(self) >= __floatVal(aNumber)) ? true : false ); |
|
418 |
} |
|
419 |
if (__isShortFloat(aNumber)) { |
|
420 |
RETURN ( (__shortFloatVal(self) >= __shortFloatVal(aNumber)) ? true : false ); |
|
421 |
} |
|
422 |
%}. |
|
423 |
^ self retry:#>= coercing:aNumber |
|
424 |
! |
|
425 |
||
426 |
hash |
|
427 |
"return a number for hashing; redefined, since floats compare |
|
428 |
by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same |
|
429 |
as 3 hash." |
|
430 |
||
431 |
|i| |
|
432 |
||
433 |
(self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[ |
|
434 |
i := self asInteger. |
|
435 |
self = i ifTrue:[ |
|
436 |
^ i hash |
|
437 |
]. |
|
438 |
]. |
|
439 |
||
440 |
" |
|
441 |
mhmh take some of my value-bits to hash on |
|
442 |
" |
|
443 |
^ (((self basicAt:4) bitAnd:16r3F) bitShift:24) + |
|
444 |
((self basicAt:3) bitShift:16) + |
|
445 |
((self basicAt:2) bitShift:8) + |
|
446 |
(self basicAt:1) |
|
447 |
||
448 |
" |
|
449 |
1.2345 hash |
|
450 |
1.2345 asShortFloat hash |
|
451 |
1.0 hash |
|
452 |
1.0 asShortFloat hash |
|
453 |
" |
|
454 |
! |
|
455 |
||
456 |
~= aNumber |
|
457 |
"return true, if the arguments value are not equal" |
|
458 |
||
459 |
%{ /* NOCONTEXT */ |
|
460 |
||
461 |
if (__isSmallInteger(aNumber)) { |
|
462 |
RETURN ( (__shortFloatVal(self) != (float)(__intVal(aNumber))) ? true : false ); |
|
463 |
} |
|
464 |
if (__isFloatLike(aNumber)) { |
|
465 |
RETURN ( (double)(__shortFloatVal(self) != __floatVal(aNumber)) ? true : false ); |
|
466 |
} |
|
467 |
if (__isShortFloat(aNumber)) { |
|
468 |
RETURN ( (__shortFloatVal(self) != __shortFloatVal(aNumber)) ? true : false ); |
|
469 |
} |
|
470 |
%}. |
|
471 |
^ self retry:#~= coercing:aNumber |
|
472 |
||
473 |
! ! |
|
474 |
||
475 |
!ShortFloat methodsFor:'printing & storing'! |
|
476 |
||
477 |
printString |
|
478 |
"return a printed representation of the receiver" |
|
479 |
||
480 |
%{ /* NOCONTEXT */ |
|
481 |
||
482 |
char buffer[64]; |
|
483 |
REGISTER char *cp; |
|
484 |
OBJ s; |
|
485 |
||
486 |
/* |
|
487 |
* actually only needed on sparc: since thisContext is |
|
488 |
* in a global register, which gets destroyed by printf, |
|
489 |
* manually save it here - very stupid ... |
|
490 |
*/ |
|
491 |
__BEGIN_PROTECT_REGISTERS__ |
|
492 |
||
493 |
#ifdef SYSV |
|
494 |
sprintf(buffer, "%.6lg", (double)__shortFloatVal(self)); |
|
495 |
#else |
|
496 |
sprintf(buffer, "%.6G", (double)__shortFloatVal(self)); |
|
497 |
#endif |
|
498 |
||
499 |
__END_PROTECT_REGISTERS__ |
|
500 |
||
501 |
/* |
|
502 |
* kludge to make integral float f prints as "f.0" (not as "f" as printf does) |
|
503 |
* (i.e. look if string contains '.' or 'e' and append '.0' if not) |
|
504 |
*/ |
|
505 |
for (cp = buffer; *cp; cp++) { |
|
506 |
if ((*cp == '.') || (*cp == 'e')) break; |
|
507 |
} |
|
508 |
if (! *cp) { |
|
509 |
*cp++ = '.'; |
|
510 |
*cp++ = '0'; |
|
511 |
*cp = '\0'; |
|
512 |
} |
|
513 |
||
514 |
s = __MKSTRING(buffer COMMA_SND); |
|
515 |
if (s != nil) { |
|
516 |
RETURN (s); |
|
517 |
} |
|
518 |
%}. |
|
519 |
" |
|
520 |
memory allocation (for the new string) failed. |
|
521 |
When we arrive here, there was no memory, even after a garbage collect. |
|
522 |
This means, that the VM wanted to get some more memory from the |
|
523 |
OS, which was not kind enough to give it. |
|
524 |
Bad luck - you should increase the swap space on your machine. |
|
525 |
" |
|
526 |
^ ObjectMemory allocationFailureSignal raise. |
|
527 |
! ! |
|
528 |
||
529 |
!ShortFloat methodsFor:'testing'! |
|
530 |
||
2387 | 531 |
isNaN |
532 |
"return true, if the receiver is an invalid float (NaN - not a number). |
|
533 |
These are not created by ST/X float operations (they raise an exception); |
|
534 |
however, inline C-code could produce them ..." |
|
535 |
||
536 |
%{ /* NOCONTEXT */ |
|
537 |
||
538 |
static float nan = 0.0 / 0.0; |
|
539 |
||
540 |
RETURN (__floatVal(self) == nan); |
|
541 |
%} |
|
542 |
||
543 |
! |
|
544 |
||
1197 | 545 |
negative |
546 |
"return true if the receiver is less than zero" |
|
547 |
||
548 |
%{ /* NOCONTEXT */ |
|
549 |
||
550 |
RETURN ( (__shortFloatVal(self) < 0.0) ? true : false ); |
|
551 |
%} |
|
552 |
||
553 |
||
554 |
! |
|
555 |
||
556 |
positive |
|
557 |
"return true if the receiver is greater or equal to zero" |
|
558 |
||
559 |
%{ /* NOCONTEXT */ |
|
560 |
||
561 |
RETURN ( (__shortFloatVal(self) >= 0.0) ? true : false ); |
|
562 |
%} |
|
563 |
||
1880 | 564 |
! |
565 |
||
566 |
strictlyPositive |
|
567 |
"return true if the receiver is greater than zero" |
|
568 |
||
569 |
%{ /* NOCONTEXT */ |
|
570 |
||
571 |
RETURN ( (__shortFloatVal(self) > 0.0) ? true : false ); |
|
572 |
%} |
|
573 |
||
1197 | 574 |
! ! |
575 |
||
1880 | 576 |
!ShortFloat class methodsFor:'documentation'! |
1197 | 577 |
|
578 |
version |
|
2387 | 579 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/SFloat.st,v 1.13 1997-02-12 15:49:25 cg Exp $' |
1197 | 580 |
! ! |