author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 19 Jan 2012 10:06:02 +0000 | |
branch | jv |
changeset 17910 | 8d796ca8bd1d |
parent 17892 | d86c8bd5ece3 |
child 17911 | a99f15c5efa5 |
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 |
" |
|
5470
5e56d8cff0c9
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5357
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
5e56d8cff0c9
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5357
diff
changeset
|
13 |
|
55 | 14 |
Number subclass:#LimitedPrecisionReal |
1200 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Magnitude-Numbers' |
|
55 | 19 |
! |
20 |
||
88 | 21 |
!LimitedPrecisionReal class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
213 | 26 |
All Rights Reserved |
55 | 27 |
|
88 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
55 | 36 |
|
88 | 37 |
documentation |
38 |
" |
|
7405 | 39 |
Abstract superclass for any-precision floating point 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 |
|
7405 | 44 |
Range and Precision of Storage Formats: |
45 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
46 |
Format | Class | Significant Digits (Binary) | Smallest Pos Number | Largest Pos Number | Significant Digits (Decimal) |
7405 | 47 |
-------+------------+-----------------------------+---------------------+--------------------+------------------------------ |
48 |
single | ShortFloat | 24 | 1.175... 10-38 | 3.402... 10+38 | 6-9 |
|
49 |
-------+------------+-----------------------------+---------------------+--------------------+------------------------------ |
|
50 |
double | Float | 53 | 2.225... 10-308 | 1.797... 10+308 | 15-17 |
|
51 |
-------+------------+-----------------------------+---------------------+--------------------+------------------------------ |
|
52 |
double | LongFloat | 113 | 3.362... 10-4932 | 1.189... 10+4932 | 33-36 |
|
53 |
ext | | | | | |
|
54 |
(SPARC)| | | | | |
|
55 |
-------+ |-----------------------------+---------------------+--------------------+------------------------------ |
|
56 |
double | | 64 | 3.362... 10-4932 | 1.189... 10+4932 | 18-21 |
|
57 |
ext | | | | | |
|
58 |
(x86) | | | | | |
|
59 |
-------+------------+-----------------------------+---------------------+--------------------+------------------------------ |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
60 |
-- | LargeFloat | arbitrary | arbitrarily small | arbitrarily large | arbitrary |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
61 |
-------+------------+-----------------------------+---------------------+--------------------+------------------------------ |
7405 | 62 |
|
63 |
||
1295 | 64 |
[author:] |
65 |
Claus Gittinger |
|
1893 | 66 |
|
67 |
[see also:] |
|
68 |
Fraction FixedPoint |
|
88 | 69 |
" |
70 |
! ! |
|
55 | 71 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
72 |
!LimitedPrecisionReal class methodsFor:'instance creation'! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
73 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
74 |
fromInteger:anInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
75 |
"return a float with anInteger's value. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
76 |
Since floats have a limited precision, you usually loose bits when doing this |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
77 |
(see Float decimalPrecision, LongFloat decimalPrecision." |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
78 |
|
9406 | 79 |
|newFloat sign absVal completeAbsVal delta mask| |
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
80 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
81 |
newFloat := self zero. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
82 |
sign := anInteger sign. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
83 |
(sign ~~ 0) ifTrue:[ |
9406 | 84 |
"be careful to do round to nearest even floating point value - |
85 |
thanks to Nicolas Cellier for this code" |
|
86 |
||
87 |
absVal := anInteger abs. |
|
88 |
delta := absVal highBit - self precision. |
|
89 |
delta > 0 ifTrue: [ |
|
90 |
completeAbsVal := absVal. |
|
91 |
"eliminate insignificant/trailing bits" |
|
92 |
absVal := absVal bitShift: delta negated. |
|
93 |
"inexact := trailingBits ~= 0. |
|
94 |
Round to nearest even" |
|
95 |
(completeAbsVal bitAt:delta) ~= 0 ifTrue:[ |
|
96 |
mask := (1 bitShift:delta-1) - 1. |
|
97 |
((completeAbsVal bitAnd:mask) ~= 0 or:[absVal odd]) ifTrue:[ |
|
98 |
absVal := absVal + 1 |
|
99 |
]. |
|
100 |
]. |
|
101 |
] ifFalse: [ |
|
102 |
delta := 0 |
|
103 |
]. |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
104 |
absVal digitLength to:1 by:-1 do:[:i | |
9406 | 105 |
newFloat := (newFloat * 256) + (absVal digitByteAt:i). |
106 |
]. |
|
107 |
delta ~~ 0 ifTrue: [ |
|
108 |
newFloat := newFloat timesTwoPower:delta. |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
109 |
]. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
110 |
(sign < 0) ifTrue:[ |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
111 |
newFloat := newFloat negated |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
112 |
] |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
113 |
]. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
114 |
^ newFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
115 |
|
9406 | 116 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
117 |
" |
9406 | 118 |
ShortFloat fromInteger:2 |
119 |
12345678901234567890 asShortFloat |
|
120 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
121 |
1234567890 asFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
122 |
1234567890 asFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
123 |
-1234567890 asFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
124 |
|
9406 | 125 |
12345678901234567890 asFloat storeString |
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
126 |
12345678901234567890 asFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
127 |
-12345678901234567890 asFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
128 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
129 |
12345678901234567890 asLongFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
130 |
12345678901234567890 asLongFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
131 |
-12345678901234567890 asLongFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
132 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
133 |
123456789012345678901234567890 asLongFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
134 |
123456789012345678901234567890 asLongFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
135 |
-123456789012345678901234567890 asLongFloat asInteger |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
136 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
137 |
1234567890123456789012345678901234567890 asLongFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
138 |
1234567890123456789012345678901234567890 asLongFloat asInteger |
9406 | 139 |
-1234567890123456789012345678901234567890 asLongFloat asInteger |
140 |
||
141 |
'this test is on 65 bits'. |
|
142 |
self assert: 16r1FFFFFFFFFFFF0801 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble. |
|
143 |
'this test is on 64 bits'. |
|
144 |
self assert: 16r1FFFFFFFFFFFF0802 asDouble ~= 16r1FFFFFFFFFFFF0800 asDouble. |
|
145 |
'nearest even is upper'. |
|
146 |
self assert: 16r1FFFFFFFFFFF1F800 asDouble = 16r1FFFFFFFFFFF20000 asDouble. |
|
147 |
'nearest even is lower'. |
|
148 |
self assert: 16r1FFFFFFFFFFFF0800 asDouble = 16r1FFFFFFFFFFFF0000 asDouble. |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
149 |
" |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
150 |
! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
151 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
152 |
fromLimitedPrecisionReal:anLPReal |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
153 |
"return a float with anLPReals value. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
154 |
You might loose bits when doing this. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
155 |
Slow fallback." |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
156 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
157 |
|fract| |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
158 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
159 |
anLPReal isFinite ifFalse:[ |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
160 |
anLPReal isNaN ifTrue:[^ self NaN]. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
161 |
anLPReal negative ifTrue:[^ self negativeInfinity]. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
162 |
^ self infinity |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
163 |
]. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
164 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
165 |
fract := anLPReal asTrueFraction. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
166 |
^ (self fromInteger:fract numerator) / (self fromInteger:fract denominator) |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
167 |
! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
168 |
|
9406 | 169 |
fromNumerator:numerator denominator:denominator |
170 |
"Create a limited precision real from a Rational. |
|
171 |
This version will answer the nearest flotaing point value, |
|
172 |
according to IEEE 754 round to nearest even default mode" |
|
173 |
||
174 |
|a b q r exponent floatExponent n ha hb hq q1 eMin zero precision nSubHq| |
|
175 |
||
176 |
a := numerator abs. |
|
177 |
b := denominator abs. |
|
178 |
ha := a highBit. |
|
179 |
hb := b highBit. |
|
180 |
||
181 |
zero := self zero. |
|
182 |
precision := self precision. |
|
183 |
||
184 |
"If both numerator and denominator are represented exactly in floating point number, |
|
185 |
then fastest thing to do is to use hardwired float division" |
|
186 |
(ha <= precision and:[hb <= precision]) ifTrue: [ |
|
187 |
^ (zero coerce:numerator) / (zero coerce:denominator) |
|
188 |
]. |
|
189 |
||
190 |
"Try and obtain a mantissa with 1 bit excess precision. |
|
191 |
First guess is rough, we might get one more bit or one less" |
|
192 |
exponent := ha - hb - precision - 1. |
|
193 |
exponent > 0 |
|
194 |
ifTrue: [b := b bitShift: exponent] |
|
195 |
ifFalse: [a := a bitShift: exponent negated]. |
|
196 |
q := a quo: b. |
|
197 |
r := a - (q * b). |
|
198 |
hq := q highBit. |
|
199 |
||
200 |
"check for gradual underflow, in which case we should use less bits" |
|
201 |
floatExponent := exponent + hq - 1. |
|
202 |
eMin := 2 - (1 bitShift: (self numBitsInExponent - 1)). |
|
203 |
n := floatExponent >= eMin |
|
204 |
ifTrue: [precision + 1] |
|
205 |
ifFalse: [precision + 1 + floatExponent - eMin]. |
|
206 |
||
207 |
nSubHq := n - hq. |
|
208 |
||
209 |
nSubHq < 0 ifTrue: [ |
|
210 |
exponent := exponent + hq - n. |
|
211 |
r := (q bitAnd: (1 bitShift:nSubHq) - 1) * b + r. |
|
212 |
q := q bitShift:nSubHq |
|
213 |
] ifFalse:[nSubHq > 0 ifTrue: [ |
|
214 |
exponent := exponent + hq - n. |
|
215 |
q1 := (r bitShift:nSubHq) quo: b. |
|
216 |
q := (q bitShift:nSubHq) bitAnd: q1. |
|
217 |
r := r - (q1 * b) |
|
218 |
]]. |
|
219 |
||
220 |
"check if we should round upward. |
|
221 |
The case of exact half (q bitAnd: 1) isZero not & (r isZero) |
|
222 |
will be handled by self fromInteger: conversion" |
|
223 |
((q bitAnd:1) ~~ 0 and:[r ~~ 0]) ifTrue:[ |
|
224 |
q := q + 1 |
|
225 |
]. |
|
226 |
||
227 |
(numerator negative xor:denominator negative) ifTrue: [ |
|
228 |
q := q negated. |
|
229 |
]. |
|
230 |
||
231 |
^ (zero coerce:q) timesTwoPower:exponent |
|
232 |
||
233 |
" |
|
234 |
Time millisecondsToRun:[ |
|
235 |
1000000 timesRepeat:[ |
|
236 |
Float fromNumerator:12345678901234567890 denominator:987654321 |
|
237 |
]. |
|
238 |
] |
|
239 |
||
240 |
|fraction| |
|
241 |
fraction := 12345678901234567890//987654321. |
|
242 |
Time millisecondsToRun:[ |
|
243 |
1000000 timesRepeat:[ |
|
244 |
fraction asFloat |
|
245 |
]. |
|
246 |
] |
|
247 |
" |
|
248 |
! |
|
249 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
250 |
new:aNumber |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
251 |
"catch this message - not allowed for floats/doubles" |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
252 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
253 |
self error:'Floats/Doubles cannot be created with new:' |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
254 |
! ! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
255 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
256 |
!LimitedPrecisionReal class methodsFor:'class initialization'! |
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
257 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
258 |
initialize |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
259 |
"initialize ANSI compliant float globals" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
260 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
261 |
Smalltalk at:#FloatE put:ShortFloat. |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
262 |
Smalltalk at:#FloatD put:Float. |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
263 |
Smalltalk at:#FloatQ put:LongFloat. |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
264 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
265 |
" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
266 |
self initialize |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
267 |
" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
268 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
269 |
"Created: / 7.9.2001 / 14:02:45 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
270 |
"Modified: / 7.9.2001 / 14:02:54 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
271 |
! ! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
272 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
273 |
!LimitedPrecisionReal class methodsFor:'constants & defaults'! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
274 |
|
7390 | 275 |
NaN |
276 |
"return the constant NaN (not a Number)." |
|
277 |
||
278 |
^ self zero uncheckedDivide:self zero |
|
279 |
||
280 |
" |
|
281 |
ShortFloat NaN |
|
282 |
Float NaN |
|
283 |
LongFloat NaN |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
284 |
LargeFloat NaN |
7390 | 285 |
" |
286 |
! |
|
287 |
||
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
288 |
e |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
289 |
"return the closest approximation of the irrational number e" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
290 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
291 |
self subclassResponsibility |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
292 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
293 |
"Modified: / 7.9.2001 / 14:05:02 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
294 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
295 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
296 |
emax |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
297 |
"return the largest exponent" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
298 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
299 |
self subclassResponsibility |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
300 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
301 |
"Created: / 7.9.2001 / 14:05:28 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
302 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
303 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
304 |
emin |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
305 |
"return the smallest exponent" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
306 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
307 |
self subclassResponsibility |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
308 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
309 |
"Created: / 7.9.2001 / 14:05:35 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
310 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
311 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
312 |
epsilon |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
313 |
"return the maximum relative spacing" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
314 |
|
9406 | 315 |
^ self radix asFloat raisedToInteger:(1 - self precision) |
6575
b07cd54c4375
Define #decimalPrecision, #epsilon
Stefan Vogel <sv@exept.de>
parents:
6195
diff
changeset
|
316 |
|
b07cd54c4375
Define #decimalPrecision, #epsilon
Stefan Vogel <sv@exept.de>
parents:
6195
diff
changeset
|
317 |
" |
7356 | 318 |
ShortFloat epsilon |
319 |
Float epsilon |
|
320 |
LongFloat epsilon |
|
6575
b07cd54c4375
Define #decimalPrecision, #epsilon
Stefan Vogel <sv@exept.de>
parents:
6195
diff
changeset
|
321 |
" |
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
322 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
323 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
324 |
fmax |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
325 |
"return the largest value allowed" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
326 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
327 |
self subclassResponsibility |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
328 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
329 |
"Created: / 7.9.2001 / 14:06:56 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
330 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
331 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
332 |
fmin |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
333 |
"return the minimum value allowed" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
334 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
335 |
self subclassResponsibility |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
336 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
337 |
"Created: / 7.9.2001 / 14:07:06 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
338 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
339 |
|
7390 | 340 |
infinity |
341 |
"return a float representing infinity" |
|
342 |
||
343 |
^ self unity uncheckedDivide:self zero |
|
344 |
||
345 |
" |
|
346 |
ShortFloat infinity |
|
347 |
Float infinity |
|
348 |
LongFloat infinity |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
349 |
LargeFloat infinity |
7390 | 350 |
" |
351 |
! |
|
352 |
||
353 |
negativeInfinity |
|
354 |
"return a float representing negative infinity" |
|
355 |
||
356 |
^ self unity negated uncheckedDivide:self zero |
|
357 |
||
358 |
" |
|
359 |
ShortFloat negativeInfinity |
|
360 |
Float negativeInfinity |
|
361 |
LongFloat negativeInfinity |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
362 |
LargeFloat negativeInfinity |
7390 | 363 |
" |
364 |
! |
|
365 |
||
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
366 |
pi |
7356 | 367 |
"return the closest approximation of the irrational number pi" |
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
368 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
369 |
self subclassResponsibility |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
370 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
371 |
"Created: / 7.9.2001 / 14:07:35 / cg" |
7356 | 372 |
! ! |
373 |
||
374 |
!LimitedPrecisionReal class methodsFor:'queries'! |
|
375 |
||
376 |
decimalPrecision |
|
377 |
"return the number of valid decimal digits" |
|
378 |
||
379 |
^ (self precision / (10.0 log:self radix)) floor |
|
380 |
||
381 |
" |
|
382 |
ShortFloat decimalPrecision |
|
383 |
Float decimalPrecision |
|
384 |
LongFloat decimalPrecision |
|
385 |
" |
|
386 |
! |
|
387 |
||
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
388 |
denormalized |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
389 |
"Return whether the instances of this class can |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
390 |
represent values in denormalized format." |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
391 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
392 |
^ true |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
393 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
394 |
|
8892 | 395 |
isAbstract |
11225 | 396 |
"Return if this class is an abstract class. |
397 |
True is returned for LimitedPrecisionReal here; false for subclasses." |
|
398 |
||
8892 | 399 |
^ self == LimitedPrecisionReal |
400 |
||
401 |
" |
|
402 |
1.0 class isAbstract |
|
403 |
" |
|
404 |
! |
|
405 |
||
7356 | 406 |
numBitsInExponent |
407 |
"return the number of bits in the exponent" |
|
408 |
||
409 |
^ self subclassResponsibility |
|
410 |
! |
|
411 |
||
412 |
numBitsInIntegerPart |
|
413 |
^ 0 |
|
414 |
! |
|
415 |
||
416 |
numBitsInMantissa |
|
417 |
"return the number of bits in the mantissa |
|
418 |
(typically 1 less than the precision due to the hidden bit)" |
|
419 |
||
420 |
^ self subclassResponsibility |
|
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
421 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
422 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
423 |
precision |
7356 | 424 |
"return the number of valid mantissa bits" |
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
425 |
|
7356 | 426 |
^ self numBitsInMantissa + 1 - self numBitsInIntegerPart |
5989
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
427 |
! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
428 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
429 |
radix |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
430 |
"return the radix (base)" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
431 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
432 |
self subclassResponsibility |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
433 |
|
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
434 |
"Created: / 7.9.2001 / 14:08:20 / cg" |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
435 |
! ! |
8e3ff880f561
ANSI preparations (incomplete)
Claus Gittinger <cg@exept.de>
parents:
5954
diff
changeset
|
436 |
|
55 | 437 |
!LimitedPrecisionReal methodsFor:'accessing'! |
438 |
||
439 |
at:index |
|
440 |
"redefined to prevent access to individual bytes in a real." |
|
441 |
||
442 |
self error:'not allowed for floats/doubles' |
|
443 |
! |
|
444 |
||
445 |
at:index put:aValue |
|
446 |
"redefined to prevent access to individual bytes in a real" |
|
447 |
||
448 |
self error:'not allowed for floats/doubles' |
|
449 |
! ! |
|
450 |
||
451 |
!LimitedPrecisionReal methodsFor:'arithmetic'! |
|
452 |
||
701 | 453 |
* aNumber |
11727 | 454 |
"return the product of the receiver and the argument." |
701 | 455 |
|
1200 | 456 |
"/ as soon as Float are float & Double are doubles, |
457 |
"/ use: |
|
458 |
"/ ^ aNumber productFromDouble:self asDouble |
|
459 |
||
460 |
^ aNumber productFromFloat:self asFloat |
|
461 |
||
462 |
"Modified: 17.4.1996 / 12:35:36 / cg" |
|
701 | 463 |
! |
464 |
||
55 | 465 |
+ aNumber |
466 |
"return the sum of the receiver and the argument, aNumber" |
|
467 |
||
1200 | 468 |
"/ as soon as Float are float & Double are doubles, |
469 |
"/ use: |
|
470 |
"/ ^ aNumber sumFromDouble:self asDouble |
|
471 |
||
472 |
^ aNumber sumFromFloat:self asFloat |
|
473 |
||
474 |
"Modified: 17.4.1996 / 12:35:55 / cg" |
|
55 | 475 |
! |
476 |
||
477 |
- aNumber |
|
478 |
"return the difference of the receiver and the argument, aNumber" |
|
479 |
||
1200 | 480 |
"/ as soon as Float are float & Double are doubles, |
481 |
"/ use: |
|
482 |
"/ ^ aNumber differenceFromDouble:self asDouble |
|
483 |
||
484 |
^ aNumber differenceFromFloat:self asFloat |
|
485 |
||
486 |
"Modified: 17.4.1996 / 12:36:07 / cg" |
|
55 | 487 |
! |
488 |
||
489 |
/ aNumber |
|
490 |
"return the quotient of the receiver and the argument, aNumber" |
|
491 |
||
492 |
((aNumber == 0) or:[aNumber = 0.0]) ifTrue:[ |
|
7141
033f2c26d8e6
replaced refs to DivisionByZeroSignal with ZeroDivide
Claus Gittinger <cg@exept.de>
parents:
6890
diff
changeset
|
493 |
^ ZeroDivide raiseRequestWith:thisContext. |
55 | 494 |
]. |
1200 | 495 |
"/ as soon as Float are float & Double are doubles, |
496 |
"/ use: |
|
497 |
"/ ^ aNumber quotientFromDouble:self asDouble |
|
498 |
||
499 |
^ aNumber quotientFromFloat:self asFloat |
|
500 |
||
4455
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
3898
diff
changeset
|
501 |
"Modified: / 17.4.1996 / 12:36:21 / cg" |
2d31d0d986be
Raise DivisionByZeroSignal proceedable (as in ST-80)!
Stefan Vogel <sv@exept.de>
parents:
3898
diff
changeset
|
502 |
"Modified: / 26.7.1999 / 10:46:11 / stefan" |
55 | 503 |
! |
504 |
||
505 |
// aNumber |
|
506 |
"return the integer quotient of dividing the receiver by aNumber with |
|
1882 | 507 |
truncation towards negative infinity." |
55 | 508 |
|
509 |
^ (self / aNumber) floor asInteger |
|
1882 | 510 |
|
511 |
"Modified: 5.11.1996 / 11:45:37 / cg" |
|
7356 | 512 |
! |
513 |
||
514 |
ceiling |
|
7398 | 515 |
^ self asTrueFraction ceiling |
7356 | 516 |
! |
517 |
||
518 |
floor |
|
7398 | 519 |
^ self asTrueFraction floor |
9406 | 520 |
! |
521 |
||
522 |
timesTwoPower:anInteger |
|
523 |
"multiply self by a power of two. |
|
524 |
Implementation takes care of preserving class and avoiding overflow/underflow |
|
525 |
Thanks to Nicolas Cellier for this code" |
|
526 |
||
17754 | 527 |
|half two h1 h2| |
9406 | 528 |
|
529 |
two := self coerce:2. |
|
530 |
||
531 |
anInteger abs highBit >= (self class numBitsInExponent - 2) ifTrue:[ |
|
532 |
half := anInteger // 2. |
|
17754 | 533 |
|
534 |
anInteger even ifTrue:[ |
|
535 |
"/ halves are equal |
|
536 |
h2 := h1 := (two raisedToInteger: half). |
|
537 |
] ifFalse:[ |
|
538 |
h1 := (two raisedToInteger: half). |
|
539 |
anInteger > 0 ifTrue:[ |
|
540 |
h2 := h1 * two. |
|
541 |
] ifFalse:[ |
|
542 |
h2 := (two raisedToInteger: anInteger - half). |
|
543 |
]. |
|
544 |
]. |
|
545 |
^ (self * h1) * h2 |
|
9406 | 546 |
] ifFalse: [ |
547 |
^ self * (two raisedToInteger: anInteger). |
|
548 |
] |
|
549 |
||
17754 | 550 |
" |
551 |
(1 asShortFloat timesTwoPower: 3) class = ShortFloat. |
|
552 |
(1 asLongFloat timesTwoPower: 1024). |
|
553 |
(1 asFloat timesTwoPower: -1024) timesTwoPower: 1024. |
|
9406 | 554 |
|
17754 | 555 |
(2.0 asShortFloat timesTwoPower: -150) timesTwoPower: 150 |
556 |
(2.0 asLongFloat timesTwoPower: -150) timesTwoPower: 150 |
|
557 |
(2.0 asFloat timesTwoPower: -150) timesTwoPower: 150 |
|
9406 | 558 |
|
17754 | 559 |
(2.0 asShortFloat timesTwoPower: -149) timesTwoPower: 149 |
560 |
(2.0 asLongFloat timesTwoPower: -149) timesTwoPower: 149 |
|
561 |
(2.0 asFloat timesTwoPower: -149) timesTwoPower: 149 |
|
562 |
||
563 |
Time millisecondsToRun:[ |
|
564 |
1000000 timesRepeat:[ |
|
565 |
(2.0 timesTwoPower: 150) |
|
566 |
] |
|
567 |
] |
|
568 |
" |
|
55 | 569 |
! ! |
570 |
||
5238 | 571 |
!LimitedPrecisionReal methodsFor:'coercing & converting'! |
55 | 572 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
573 |
asFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
574 |
^ Float fromLimitedPrecisionReal:self |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
575 |
! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
576 |
|
55 | 577 |
asFraction |
5883 | 578 |
"Answer a rational number (Integer or Fraction) representing the receiver. |
579 |
This conversion uses the continued fraction method to approximate |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
580 |
a floating point number. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
581 |
In contrast to #asTrueFraction, which returns exactly the value of the float, |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
582 |
this rounds in the last significant bit of the floating point number. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
583 |
" |
5883 | 584 |
|
585 |
|num1 denom1 num2 denom2 int frac newD temp limit| |
|
55 | 586 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
587 |
self isFinite ifFalse:[ |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
588 |
"/ ^ self asMetaNumber. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
589 |
^ self class |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
590 |
raise:#domainErrorSignal |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
591 |
receiver:self |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
592 |
selector:#asFraction |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
593 |
arguments:#() |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
594 |
errorString:'Cannot represent non-finite number as fraction' |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
595 |
]. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
596 |
|
7394 | 597 |
limit := 10 raisedToInteger:self defaultNumberOfDigits. |
5883 | 598 |
num1 := self truncated. |
599 |
denom1 := 1. "The first of two alternating denominators" |
|
600 |
num2 := 1. "The second numerator" |
|
601 |
denom2 := 0. "The second denominator--will update" |
|
602 |
int := num1. "The integer part of self" |
|
603 |
frac := self fractionPart. |
|
604 |
[frac = 0] whileFalse:[ |
|
605 |
newD := 1.0 / frac. |
|
606 |
int := newD truncated. |
|
607 |
frac := newD fractionPart. "save the fractional part for next time" |
|
608 |
temp := num2. "old numerator and save it" |
|
609 |
num2 := num1. |
|
610 |
num1 := num1 * int + temp. "Update first numerator" |
|
611 |
temp := denom2. "old denominator and save it" |
|
612 |
denom2 := denom1. |
|
613 |
denom1 := int * denom1 + temp. "Update first denominator" |
|
614 |
limit < denom1 ifTrue:[ |
|
615 |
"Is ratio past float precision? If so, pick which of the two ratios to use" |
|
616 |
num2 = 0.0 ifTrue:[ |
|
617 |
"Is second denominator 0?" |
|
618 |
^ Fraction numerator:num1 denominator:denom1 |
|
619 |
]. |
|
620 |
^ Fraction numerator:num2 denominator:denom2 |
|
621 |
] |
|
3060 | 622 |
]. |
623 |
||
5883 | 624 |
"If fractional part is zero, return the first ratio" |
625 |
denom1 = 1 ifTrue:[ |
|
626 |
"Am i really an Integer?" |
|
627 |
^ num1 "Yes, return Integer result" |
|
3060 | 628 |
]. |
5883 | 629 |
"Otherwise return Fraction result" |
630 |
^ Fraction numerator:num1 denominator:denom1 |
|
55 | 631 |
|
3060 | 632 |
" |
5883 | 633 |
1.1 asFraction |
634 |
1.2 asFraction |
|
635 |
0.3 asFraction |
|
7394 | 636 |
0.5 asFraction |
637 |
(1/5) asFloat asFraction |
|
5883 | 638 |
(1/8) asFloat asFraction |
639 |
(1/13) asFloat asFraction |
|
640 |
3.14159 asFraction |
|
641 |
3.14159 asFraction asFloat |
|
7394 | 642 |
1.3 asFraction |
643 |
1.0 asFraction |
|
644 |
1E6 asFraction |
|
645 |
1E-6 asFraction |
|
3060 | 646 |
" |
2793 | 647 |
|
3060 | 648 |
"Modified: / 25.10.1997 / 16:41:19 / cg" |
55 | 649 |
! |
650 |
||
651 |
asInteger |
|
652 |
"return an integer with same value - might truncate" |
|
653 |
||
3185 | 654 |
|max maxF| |
55 | 655 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
656 |
self isFinite ifFalse:[ |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
657 |
"/ ^ self asMetaNumber. |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
658 |
^ self class |
7418
521174de046d
Nan asInteger raises DomainError
Claus Gittinger <cg@exept.de>
parents:
7405
diff
changeset
|
659 |
raise:#domainErrorSignal |
3395
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
660 |
receiver:self |
02f47135d80f
pass messageSend as parameter to domainError exception
Claus Gittinger <cg@exept.de>
parents:
3225
diff
changeset
|
661 |
selector:#asInteger |
6195 | 662 |
arguments:#() |
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
663 |
errorString:'Cannot represent non-finite number as integer' |
2388 | 664 |
]. |
665 |
||
4615
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
666 |
self abs < 2e16 ifTrue:[ |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
667 |
"/ NOTICE: this must be redefined in float |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
668 |
"/ subclasses to handle the smallinteger range; |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
669 |
"/ i.e. this may only be invoked for reals |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
670 |
"/ which are NOT within the smallInt range. |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
671 |
"/ otherwise, endless recursion is the consequence. |
3426 | 672 |
|
4615
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
673 |
max := SmallInteger maxVal // 2 + 1. |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
674 |
maxF := max asFloat. |
3426 | 675 |
|
4615
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
676 |
^ (self quo:maxF) * max + (self rem:maxF) truncated |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
677 |
]. |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
678 |
^ self asTrueFraction |
55 | 679 |
|
3137 | 680 |
" |
4615
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
681 |
12345.0 asInteger |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
682 |
1e15 asInteger |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
683 |
1e33 asInteger asFloat |
e480d1e6090f
largFloat -> largeInt conversion fixed.
Claus Gittinger <cg@exept.de>
parents:
4455
diff
changeset
|
684 |
1e303 asInteger asFloat |
3137 | 685 |
" |
2388 | 686 |
|
6195 | 687 |
"Modified: / 16.11.2001 / 14:15:33 / cg" |
701 | 688 |
! |
689 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
690 |
asLargeFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
691 |
^ LargeFloat fromLimitedPrecisionReal:self |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
692 |
! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
693 |
|
7378 | 694 |
asLimitedPrecisionReal |
695 |
"return a float of any precision with same value" |
|
696 |
||
697 |
^ self |
|
698 |
! |
|
699 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
700 |
asLongFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
701 |
^ LongFloat fromLimitedPrecisionReal:self |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
702 |
! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
703 |
|
5883 | 704 |
asRational |
705 |
"Answer a Rational number--Integer or Fraction--representing the receiver. |
|
706 |
Same as asFraction fro st-80 compatibility." |
|
707 |
||
708 |
^ self asFraction |
|
709 |
||
710 |
" |
|
711 |
1.1 asRational |
|
712 |
1.2 asRational |
|
713 |
0.3 asRational |
|
714 |
0.5 asRational |
|
715 |
(1/5) asFloat asRational |
|
716 |
(1/8) asFloat asRational |
|
717 |
(1/13) asFloat asRational |
|
718 |
3.14159 asRational |
|
719 |
3.14159 asRational asFloat |
|
720 |
1.3 asRational |
|
721 |
1.0 asRational |
|
722 |
" |
|
723 |
! |
|
724 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
725 |
asShortFloat |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
726 |
^ ShortFloat fromLimitedPrecisionReal:self |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
727 |
! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
728 |
|
7356 | 729 |
asTrueFraction |
730 |
"Answer a fraction or integer that EXACTLY represents self, |
|
731 |
an any-precision IEEE floating point number, consisting of: |
|
732 |
numMantissaBits bits of normalized mantissa (i.e. with hidden leading 1-bit) |
|
733 |
optional numExtraBits between mantissa and exponent (normalized flag for ext-real) |
|
734 |
numExponentBits bits of 2s complement exponent |
|
735 |
1 sign bit. |
|
736 |
Taken from Floats asTrueFraction" |
|
737 |
||
738 |
|shifty sign expPart exp fraction fractionPart result zeroBitsCount |
|
739 |
numBytes numBits numBitsInMantissa maskMantissa numBitsInExponent maskExponent |
|
740 |
biasExponent numIntegerBits| |
|
741 |
||
742 |
self isFinite ifFalse:[ |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
743 |
"/ ^ self asMetaNumber |
7356 | 744 |
^ self class |
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
745 |
raise:#domainErrorSignal |
7356 | 746 |
receiver:self |
747 |
selector:#asTrueFraction |
|
748 |
arguments:#() |
|
749 |
errorString:'Cannot represent non-finite float as a fraction'. |
|
750 |
]. |
|
751 |
||
752 |
"Extract the bits of an IEEE anySize float " |
|
753 |
numBytes := self basicSize. |
|
754 |
numBitsInMantissa := self class numBitsInMantissa. maskMantissa := (1 bitShift:numBitsInMantissa) - 1. |
|
755 |
numBitsInExponent := self class numBitsInExponent. maskExponent := (1 bitShift:numBitsInExponent) - 1. |
|
756 |
numIntegerBits := self class numBitsInIntegerPart. |
|
757 |
numBits := numBitsInMantissa + numBitsInExponent. "not (numBytes * 8 - 1) -- there could be 80 float bits in 96 overall bits" |
|
758 |
biasExponent := maskExponent bitShift:-1. |
|
759 |
||
760 |
shifty := LargeInteger basicNew numberOfDigits:numBytes. |
|
761 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
762 |
1 to:numBytes do:[:i | shifty digitAt:(numBytes+1-i) put:(self basicAt:i)]. |
|
763 |
] ifFalse:[ |
|
764 |
1 to:numBytes do:[:i | shifty digitAt:i put:(self basicAt:i)]. |
|
765 |
]. |
|
766 |
||
767 |
" Extract the sign and the biased exponent " |
|
768 |
sign := (shifty bitAt:numBits+1) == 0 ifTrue: [1] ifFalse: [-1]. |
|
769 |
expPart := (shifty bitShift:numBitsInMantissa negated) bitAnd: maskExponent. |
|
770 |
||
771 |
" Extract fractional part; answer 0 if this is a true 0.0 value " |
|
772 |
fractionPart := shifty bitAnd:maskMantissa. |
|
773 |
( expPart=0 and: [ fractionPart=0 ] ) ifTrue: [ ^ 0 ]. |
|
701 | 774 |
|
7356 | 775 |
numIntegerBits == 0 ifTrue:[ |
776 |
" Replace omitted leading 1 in fraction (Notice: quadIEEE format does not do this)" |
|
777 |
fraction := fractionPart bitOr: (maskMantissa + 1). |
|
778 |
] ifFalse:[ |
|
779 |
fraction := fractionPart. |
|
780 |
]. |
|
781 |
||
7390 | 782 |
"Unbias exponent" |
7356 | 783 |
exp := biasExponent - expPart + (numBitsInMantissa - numIntegerBits). |
1200 | 784 |
|
7390 | 785 |
" Form the result. When exp>fractionalPrecision, the exponent is adjusted by |
7356 | 786 |
the number of trailing zero bits in the fraction to minimize |
7390 | 787 |
the (huge) time otherwise spent in #gcd: of fraction handling code." |
7356 | 788 |
exp negative ifTrue: [ |
7480 | 789 |
result := sign * (fraction bitShift: exp negated) |
7356 | 790 |
] ifFalse:[ |
791 |
zeroBitsCount := fraction lowBit - 1. |
|
792 |
exp := exp - zeroBitsCount. |
|
793 |
exp <= 0 ifTrue: [ |
|
794 |
zeroBitsCount := zeroBitsCount + exp. |
|
7480 | 795 |
result := sign * (fraction bitShift:zeroBitsCount negated) |
7356 | 796 |
] ifFalse: [ |
797 |
result := Fraction |
|
7480 | 798 |
numerator: (sign * (fraction bitShift: zeroBitsCount negated)) |
7356 | 799 |
denominator: (1 bitShift:exp) |
800 |
] |
|
801 |
]. |
|
1200 | 802 |
|
7356 | 803 |
"Low cost validation omitted after extensive testing" |
804 |
"(result asFloat = self) ifFalse: [self error: 'asTrueFraction validation failed']." |
|
805 |
||
806 |
^ result |
|
807 |
||
808 |
" |
|
7390 | 809 |
0.3 asFloat asTrueFraction |
7356 | 810 |
0.3 asShortFloat asTrueFraction |
7390 | 811 |
0.3 asLongFloat asTrueFraction |
812 |
||
813 |
1.25 asTrueFraction |
|
7480 | 814 |
1.25 asShortFloat asTrueFraction |
7390 | 815 |
0.25 asTrueFraction |
816 |
-0.25 asTrueFraction |
|
817 |
3e37 asTrueFraction |
|
818 |
||
819 |
Float NaN asTrueFraction -> error |
|
820 |
Float infinity asTrueFraction -> error |
|
821 |
Float negativeInfinity asTrueFraction -> error |
|
822 |
" |
|
823 |
! |
|
824 |
||
825 |
exponent |
|
826 |
"extract a normalized floats exponent. |
|
827 |
The returned value depends on the float-representation of |
|
828 |
the underlying machine and is therefore highly unportable. |
|
829 |
This is not for general use. |
|
830 |
This assumes that the mantissa is normalized to |
|
831 |
0.5 .. 1.0 and the floats value is mantissa * 2^exp" |
|
832 |
||
833 |
|shifty expPart exp numBytes numBitsInMantissa maskMantissa numBitsInExponent maskExponent |
|
834 |
biasExponent numIntegerBits fractionPart| |
|
7356 | 835 |
|
7390 | 836 |
"Extract the bits of an IEEE anySize float " |
837 |
numBytes := self basicSize. |
|
838 |
numBitsInMantissa := self class numBitsInMantissa. maskMantissa := (1 bitShift:numBitsInMantissa) - 1. |
|
839 |
numBitsInExponent := self class numBitsInExponent. maskExponent := (1 bitShift:numBitsInExponent) - 1. |
|
840 |
numIntegerBits := self class numBitsInIntegerPart. |
|
841 |
biasExponent := maskExponent bitShift:-1. |
|
842 |
||
843 |
shifty := LargeInteger basicNew numberOfDigits:numBytes. |
|
844 |
UninterpretedBytes isBigEndian ifTrue:[ |
|
845 |
1 to:numBytes do:[:i | shifty digitAt:(numBytes+1-i) put:(self basicAt:i)]. |
|
846 |
] ifFalse:[ |
|
847 |
1 to:numBytes do:[:i | shifty digitAt:i put:(self basicAt:i)]. |
|
848 |
]. |
|
849 |
||
850 |
" Extract the sign and the biased exponent " |
|
851 |
expPart := (shifty bitShift:numBitsInMantissa negated) bitAnd: maskExponent. |
|
852 |
||
853 |
" Extract fractional part; answer 0 if this is a true 0.0 value " |
|
854 |
fractionPart := shifty bitAnd:maskMantissa. |
|
855 |
( expPart=0 and: [ fractionPart=0 ] ) ifTrue: [ ^ 0 ]. |
|
856 |
||
857 |
exp := expPart - biasExponent + 1. |
|
858 |
^ exp |
|
859 |
||
860 |
" |
|
861 |
0.3 asFloat exponent |
|
862 |
0.3 asShortFloat exponent |
|
863 |
0.3 asLongFloat exponent |
|
864 |
||
865 |
0.0 exponent2 0 |
|
866 |
1.0 exponent2 1 |
|
867 |
2.0 exponent2 2 |
|
868 |
3.0 exponent2 2 |
|
869 |
4.0 exponent2 3 |
|
870 |
0.5 exponent2 0 |
|
871 |
0.4 exponent2 -1 |
|
872 |
0.25 exponent2 -1 |
|
873 |
0.00000011111 exponent2 -23 |
|
7356 | 874 |
" |
701 | 875 |
! |
876 |
||
3898 | 877 |
fractionalPart |
878 |
"This has been renamed to #fractionPart for ST80 compatibility. |
|
879 |
||
880 |
extract the after-decimal fraction part. |
|
881 |
the floats value is |
|
882 |
float truncated + float fractionalPart" |
|
883 |
||
5868 | 884 |
<resource:#obsolete> |
885 |
||
3898 | 886 |
self obsoleteMethodWarning:'please use #fractionPart'. |
887 |
^ self fractionPart |
|
888 |
||
889 |
"Modified: / 28.10.1998 / 17:10:12 / cg" |
|
890 |
"Created: / 28.10.1998 / 17:10:32 / cg" |
|
701 | 891 |
! ! |
892 |
||
893 |
!LimitedPrecisionReal methodsFor:'comparing'! |
|
894 |
||
895 |
< aNumber |
|
896 |
"return true, if the argument is greater" |
|
897 |
||
1201
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
898 |
"/ 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
|
899 |
"/ use: |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
900 |
"/ ^ aNumber lessFromDouble:self asDouble |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
901 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
902 |
^ aNumber lessFromFloat:self asFloat |
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
903 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
904 |
"Modified: 17.4.1996 / 13:34:50 / cg" |
701 | 905 |
! ! |
906 |
||
907 |
!LimitedPrecisionReal methodsFor:'copying'! |
|
908 |
||
909 |
deepCopy |
|
910 |
"return a deep copy of myself |
|
911 |
- because storing into floats is not recommended/allowed, its ok to return the receiver" |
|
912 |
||
913 |
^ self |
|
914 |
! |
|
915 |
||
10946 | 916 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
701 | 917 |
"return a deep copy of myself |
918 |
- because storing into floats is not recommended/allowed, its ok to return the receiver" |
|
919 |
||
920 |
^ self |
|
921 |
! |
|
922 |
||
923 |
shallowCopy |
|
924 |
"return a shallow copy of the receiver" |
|
925 |
||
926 |
^ self |
|
927 |
! |
|
928 |
||
929 |
simpleDeepCopy |
|
930 |
"return a deep copy of the receiver |
|
931 |
- because storing into floats is not recommended/allowed, its ok to return the receiver" |
|
932 |
||
933 |
^ self |
|
55 | 934 |
! ! |
935 |
||
936 |
!LimitedPrecisionReal methodsFor:'double dispatching'! |
|
937 |
||
938 |
differenceFromFraction:aFraction |
|
213 | 939 |
"sent when a fraction does not know how to subtract the receiver, a float" |
55 | 940 |
|
941 |
|d| |
|
942 |
||
943 |
d := aFraction denominator. |
|
944 |
^ (aFraction numerator - (self * d)) / d |
|
945 |
! |
|
946 |
||
11516 | 947 |
differenceFromTimestamp:aTimestamp |
948 |
"I am to be interpreted as seconds, return the timestamp this number of seconds |
|
949 |
before aTimestamp" |
|
950 |
||
951 |
^ aTimestamp subtractMilliseconds:(self * 1000) truncated. |
|
952 |
||
953 |
" |
|
954 |
Timestamp now differenceFromTimestamp:aTimestamp |
|
955 |
100.0 differenceFromTimestamp:Timestamp now |
|
956 |
||
957 |
|t1 t2| |
|
958 |
t1 := Timestamp now. |
|
959 |
t2 := 1.5 differenceFromTimestamp:t1. |
|
960 |
t1 inspect. t2 inspect. |
|
961 |
" |
|
962 |
! |
|
963 |
||
55 | 964 |
productFromFraction:aFraction |
213 | 965 |
"sent when a fraction does not know how to multiply the receiver, a float" |
55 | 966 |
|
967 |
^ self * aFraction numerator / aFraction denominator |
|
968 |
! |
|
969 |
||
970 |
quotientFromFraction:aFraction |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
971 |
"Return the quotient of the argument, aFraction and the receiver. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
972 |
Sent when aFraction does not know how to divide by the receiver." |
55 | 973 |
|
974 |
^ aFraction numerator / (self * aFraction denominator) |
|
701 | 975 |
! |
976 |
||
977 |
sumFromFraction:aFraction |
|
978 |
"sent when a fraction does not know how to add the receiver, a float" |
|
979 |
||
980 |
|d| |
|
981 |
||
982 |
d := aFraction denominator. |
|
983 |
^ (self * d + aFraction numerator) / d |
|
10680 | 984 |
! |
985 |
||
986 |
sumFromTimestamp:aTimestamp |
|
987 |
"I am to be interpreted as seconds, return the timestamp this number of seconds |
|
988 |
after aTimestamp" |
|
989 |
||
990 |
^ aTimestamp addMilliseconds:(self * 1000) truncated. |
|
991 |
||
992 |
" |
|
993 |
Timestamp now sumFromTimestamp:aTimestamp |
|
994 |
100.0 sumFromTimestamp:Timestamp now |
|
995 |
||
996 |
|t1 t2| |
|
997 |
t1 := Timestamp now. |
|
998 |
t2 := 1.5 sumFromTimestamp:t1. |
|
999 |
t1 inspect. t2 inspect. |
|
1000 |
" |
|
701 | 1001 |
! ! |
1002 |
||
1003 |
!LimitedPrecisionReal methodsFor:'printing & storing'! |
|
1004 |
||
1005 |
printOn:aStream |
|
1006 |
"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
|
1007 |
the argument, aStream. |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1008 |
|
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1009 |
LimitedPrecisonReal and its subclasses use #printString instead of |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1010 |
#printOn: as basic print mechanism." |
701 | 1011 |
|
1012 |
aStream nextPutAll:self printString |
|
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1013 |
|
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1014 |
"Modified: / 20.1.1998 / 14:10:46 / stefan" |
1200 | 1015 |
! |
1016 |
||
1017 |
printString |
|
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1018 |
"return a printed representation of the receiver |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1019 |
LimitedPrecisonReal and its subclasses use #printString instead of |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1020 |
#printOn: as basic print mechanism." |
1200 | 1021 |
|
1022 |
^ self subclassResponsibility |
|
1023 |
||
3194
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1024 |
"Created: / 17.4.1996 / 12:12:20 / cg" |
16073834a825
Add comment about #printOn: and #printString
Stefan Vogel <sv@exept.de>
parents:
3185
diff
changeset
|
1025 |
"Modified: / 20.1.1998 / 14:10:47 / stefan" |
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1026 |
! |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1027 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1028 |
storeOn:aStream |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1029 |
"append a printed representation of the receiver to |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1030 |
the argument, aStream. |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1031 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1032 |
LimitedPrecisonReal and its subclasses use #storeString instead of |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1033 |
#storeOn: as basic store mechanism." |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1034 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1035 |
aStream nextPutAll:self storeString |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1036 |
! |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1037 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1038 |
storeString |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1039 |
"return a printed representation of the receiver |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1040 |
LimitedPrecisonReal and its subclasses use #storeString instead of |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1041 |
#storeOn: as basic print mechanism." |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1042 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1043 |
^ self subclassResponsibility |
701 | 1044 |
! ! |
1045 |
||
5557 | 1046 |
!LimitedPrecisionReal methodsFor:'queries'! |
1047 |
||
5883 | 1048 |
defaultNumberOfDigits |
7356 | 1049 |
"Answer how many digits of accuracy this class supports" |
1050 |
||
1051 |
^ self class decimalPrecision - 1 |
|
8422
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1052 |
|
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1053 |
" |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1054 |
Float new defaultNumberOfDigits |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1055 |
LongFloat new defaultNumberOfDigits |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1056 |
ShortFloat new defaultNumberOfDigits |
c206b4711b6e
Define #storeString to not use DecimalPointCharacter and to
Stefan Vogel <sv@exept.de>
parents:
8395
diff
changeset
|
1057 |
" |
5883 | 1058 |
! |
1059 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1060 |
precision |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1061 |
"return the number of valid mantissa bits. |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1062 |
Should be redefined in classes which allow per-instance precision specification" |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1063 |
|
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1064 |
^ self class precision |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1065 |
! |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1066 |
|
5557 | 1067 |
size |
1068 |
"redefined since reals are kludgy (ByteArry)" |
|
1069 |
||
1070 |
^ 0 |
|
1071 |
! ! |
|
5470
5e56d8cff0c9
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5357
diff
changeset
|
1072 |
|
17845 | 1073 |
|
701 | 1074 |
!LimitedPrecisionReal methodsFor:'testing'! |
1075 |
||
3148
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1076 |
isFinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1077 |
^ self subclassResponsibility |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1078 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1079 |
"Created: / 7.1.1998 / 12:02:06 / stefan" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1080 |
! |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1081 |
|
6185 | 1082 |
isFloat |
1083 |
"return true, if the receiver is some kind of floating point number; |
|
1084 |
false is returned here. |
|
1085 |
Same as #isLimitedPrecisionReal, but a better name ;-)" |
|
1086 |
||
1087 |
^ true |
|
1088 |
||
1089 |
"Created: / 14.11.2001 / 14:57:55 / cg" |
|
1090 |
! |
|
1091 |
||
3148
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1092 |
isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1093 |
"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
|
1094 |
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
|
1095 |
however, inline C-code could produce them ..." |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1096 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1097 |
^ (self isFinite or:[self isNaN]) not. |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1098 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1099 |
" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1100 |
1.0 isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1101 |
(0.0 uncheckedDivide: 0.0) isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1102 |
(1.0 uncheckedDivide: 0.0) isInfinite |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1103 |
" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1104 |
|
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1105 |
"Modified: / 7.1.1998 / 12:01:30 / stefan" |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1106 |
! |
1434542209e7
New #finite, define #isInfinite using #finite.
Stefan Vogel <sv@exept.de>
parents:
3137
diff
changeset
|
1107 |
|
6086
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
5989
diff
changeset
|
1108 |
isLimitedPrecisionReal |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
5989
diff
changeset
|
1109 |
"return true, if the receiver is some kind of limited precision real (i.e. floating point) number; |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
5989
diff
changeset
|
1110 |
true is returned here - the method is redefined from Object." |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
5989
diff
changeset
|
1111 |
|
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
5989
diff
changeset
|
1112 |
^ true |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
5989
diff
changeset
|
1113 |
! |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
5989
diff
changeset
|
1114 |
|
2388 | 1115 |
isNaN |
1116 |
^ self subclassResponsibility |
|
1117 |
||
1118 |
"Modified: 12.2.1997 / 16:45:27 / cg" |
|
1119 |
! |
|
1120 |
||
6890
8e74eff54c3d
added isNegativeZero to test for -0.0
Claus Gittinger <cg@exept.de>
parents:
6641
diff
changeset
|
1121 |
isNegativeZero |
8e74eff54c3d
added isNegativeZero to test for -0.0
Claus Gittinger <cg@exept.de>
parents:
6641
diff
changeset
|
1122 |
"many systems have two float.Pnt zeros" |
8e74eff54c3d
added isNegativeZero to test for -0.0
Claus Gittinger <cg@exept.de>
parents:
6641
diff
changeset
|
1123 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1124 |
^ (self isZero) and:[self printString first == $-] |
6890
8e74eff54c3d
added isNegativeZero to test for -0.0
Claus Gittinger <cg@exept.de>
parents:
6641
diff
changeset
|
1125 |
|
8e74eff54c3d
added isNegativeZero to test for -0.0
Claus Gittinger <cg@exept.de>
parents:
6641
diff
changeset
|
1126 |
" |
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1127 |
0.0 asLongFloat isNegativeZero |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1128 |
-0.0 asLongFloat isNegativeZero |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1129 |
-1.0 asLongFloat isNegativeZero |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1130 |
1.0 asLongFloat isNegativeZero |
7356 | 1131 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1132 |
0.0 asLargeFloat isNegativeZero |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1133 |
-0.0 asLargeFloat isNegativeZero |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1134 |
" |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1135 |
" |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1136 |
0.0 asLongFloat isZero |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1137 |
-0.0 asLongFloat isZero |
701 | 1138 |
|
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1139 |
0.0 > 0 |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1140 |
-0.0 < 0 |
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1141 |
" |
701 | 1142 |
! |
1143 |
||
5357 | 1144 |
numberOfBits |
1145 |
"return the size (in bits) of the real; |
|
1146 |
typically, this is 64 for Floats and 32 for ShortFloats, |
|
1147 |
but who knows ..." |
|
1148 |
||
1149 |
self subclassResponsibility |
|
1150 |
! |
|
1151 |
||
701 | 1152 |
positive |
1153 |
"return true if the receiver is greater or equal to zero" |
|
1154 |
||
7447
64fab8614c76
double dispatching, converting
Claus Gittinger <cg@exept.de>
parents:
7418
diff
changeset
|
1155 |
^ self sign >= 0 |
1201
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
1156 |
|
24a5faa7e305
oops - asDouble is not yet there
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
1157 |
"Modified: 17.4.1996 / 13:35:10 / cg" |
55 | 1158 |
! ! |
1159 |
||
7356 | 1160 |
!LimitedPrecisionReal methodsFor:'truncation & rounding'! |
1161 |
||
1162 |
ceilingAsFloat |
|
1163 |
^ self coerce:(self ceiling). |
|
1164 |
||
1165 |
" |
|
1166 |
0.4 asLongFloat ceilingAsFloat |
|
1167 |
" |
|
1168 |
! |
|
1169 |
||
1170 |
floorAsFloat |
|
1171 |
^ self coerce:(self floor). |
|
1172 |
||
1173 |
" |
|
1174 |
0.4 asLongFloat floorAsFloat |
|
1175 |
" |
|
1176 |
! |
|
1177 |
||
1178 |
roundedAsFloat |
|
1179 |
self negative ifTrue:[ ^ (self - 0.5) ceilingAsFloat ]. |
|
1180 |
^ (self + 0.5) floorAsFloat |
|
7398 | 1181 |
! |
1182 |
||
1183 |
truncatedAsFloat |
|
1184 |
^ self coerce:(self truncated). |
|
1185 |
||
1186 |
" |
|
1187 |
0.4 asLongFloat truncatedAsFloat |
|
1188 |
" |
|
7356 | 1189 |
! ! |
1190 |
||
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8202
diff
changeset
|
1191 |
!LimitedPrecisionReal methodsFor:'visiting'! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8202
diff
changeset
|
1192 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8202
diff
changeset
|
1193 |
acceptVisitor:aVisitor with:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8202
diff
changeset
|
1194 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8202
diff
changeset
|
1195 |
^ aVisitor visitFloat:self with:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8202
diff
changeset
|
1196 |
! ! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8202
diff
changeset
|
1197 |
|
701 | 1198 |
!LimitedPrecisionReal class methodsFor:'documentation'! |
55 | 1199 |
|
701 | 1200 |
version |
17892 | 1201 |
^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.72 2010/03/06 11:27:34 cg Exp $' |
17732
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
1202 |
! |
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
1203 |
|
a1892eeca6c0
trunk merged into jv branch
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
1204 |
version_CVS |
17845 | 1205 |
^ '§Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.72 2010/03/06 11:27:34 cg Exp §' |
17865 | 1206 |
! |
1207 |
||
1208 |
version_SVN |
|
17910 | 1209 |
^ '$Id: LimitedPrecisionReal.st 10758 2012-01-19 10:06:02Z vranyj1 $' |
55 | 1210 |
! ! |
6890
8e74eff54c3d
added isNegativeZero to test for -0.0
Claus Gittinger <cg@exept.de>
parents:
6641
diff
changeset
|
1211 |
|
17846 | 1212 |
LimitedPrecisionReal initialize! |
17892 | 1213 |
|
17910 | 1214 |