equal
deleted
inserted
replaced
18 ! |
18 ! |
19 |
19 |
20 Float comment:' |
20 Float comment:' |
21 COPYRIGHT (c) 1988 by Claus Gittinger |
21 COPYRIGHT (c) 1988 by Claus Gittinger |
22 All Rights Reserved |
22 All Rights Reserved |
|
23 |
|
24 $Header: /cvs/stx/stx/libbasic/Float.st,v 1.16 1994-08-05 00:54:50 claus Exp $ |
23 '! |
25 '! |
24 |
26 |
25 !Float class methodsFor:'documentation'! |
27 !Float class methodsFor:'documentation'! |
26 |
28 |
27 copyright |
29 copyright |
38 " |
40 " |
39 ! |
41 ! |
40 |
42 |
41 version |
43 version |
42 " |
44 " |
43 $Header: /cvs/stx/stx/libbasic/Float.st,v 1.15 1994-06-02 16:20:22 claus Exp $ |
45 $Header: /cvs/stx/stx/libbasic/Float.st,v 1.16 1994-08-05 00:54:50 claus Exp $ |
44 " |
46 " |
45 ! |
47 ! |
46 |
48 |
47 documentation |
49 documentation |
48 " |
50 " |
67 will always coerce them, effectively slowing things down. |
69 will always coerce them, effectively slowing things down. |
68 This may be changed, to use a flag bit in the class. |
70 This may be changed, to use a flag bit in the class. |
69 |
71 |
70 Class Variables: |
72 Class Variables: |
71 |
73 |
72 LastErrorNumber <Integer> value of errno (after a trig- or other math err) |
74 LastErrorNumber <Integer> value of errno (after a trig- or other math err) |
73 " |
75 " |
74 ! ! |
76 ! ! |
75 |
77 |
76 !Float class methodsFor:'instance creation'! |
78 !Float class methodsFor:'instance creation'! |
77 |
79 |
358 RETURN ( (_floatVal(self) != _floatVal(aNumber)) ? true : false ); |
360 RETURN ( (_floatVal(self) != _floatVal(aNumber)) ? true : false ); |
359 } |
361 } |
360 %} |
362 %} |
361 . |
363 . |
362 ^ self retry:#~= coercing:aNumber |
364 ^ self retry:#~= coercing:aNumber |
|
365 ! |
|
366 |
|
367 hash |
|
368 "return a number for hashing; redefined, since floats compare |
|
369 by numeric value (i.e. 3.0 = 3), therefore 3.0 hash must be the same |
|
370 as 3 hash." |
|
371 |
|
372 |i idx| |
|
373 |
|
374 (self >= SmallInteger minVal and:[self <= SmallInteger maxVal]) ifTrue:[ |
|
375 i := self asInteger. |
|
376 self = i ifTrue:[ |
|
377 ^ i hash |
|
378 ]. |
|
379 ]. |
|
380 |
|
381 " |
|
382 mhmh take my value-bits to hash on |
|
383 " |
|
384 idx := self basicSize. |
|
385 ^ (((self basicAt:idx) bitAnd:16r3F) bitShift:24) + |
|
386 ((self basicAt:idx-1) bitShift:16) + |
|
387 ((self basicAt:idx-2) bitShift:8) + |
|
388 (self basicAt:idx-3) |
|
389 |
|
390 " |
|
391 3 hash |
|
392 3.0 hash |
|
393 3.1 hash |
|
394 3.14159 hash |
|
395 31.4159 hash |
|
396 3.141591 hash |
|
397 1.234567890123456 hash |
|
398 1.234567890123457 hash |
|
399 Set withAll:#(3 3.0 99 99.0 3.1415) |
|
400 " |
363 ! ! |
401 ! ! |
364 |
402 |
365 !Float methodsFor:'coercion and converting'! |
403 !Float methodsFor:'coercion and converting'! |
366 |
404 |
367 coerce:aNumber |
405 coerce:aNumber |
770 storeBinaryDefinitionOn: stream manager: manager |
808 storeBinaryDefinitionOn: stream manager: manager |
771 manager putIdOf: self class on: stream. |
809 manager putIdOf: self class on: stream. |
772 Float storeBinaryIEEEDouble:self on:stream. |
810 Float storeBinaryIEEEDouble:self on:stream. |
773 ! ! |
811 ! ! |
774 |
812 |
775 !Float methodsFor:'printing and storing'! |
813 !Float methodsFor:'printing & storing'! |
776 |
814 |
777 printString |
815 printString |
778 "return a printed representation of the receiver" |
816 "return a printed representation of the receiver" |
779 |
817 |
780 %{ /* NOCONTEXT */ |
818 %{ /* NOCONTEXT */ |