author | Claus Gittinger <cg@exept.de> |
Fri, 24 Mar 2000 12:54:44 +0100 | |
changeset 5322 | 411b6c0f7250 |
parent 4658 | 1a74754fbe91 |
child 5364 | a27f5167822c |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
213 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Number subclass:#Fraction |
|
1200 | 14 |
instanceVariableNames:'numerator denominator' |
15 |
classVariableNames:'FractionOne FractionZero' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Magnitude-Numbers' |
|
1 | 18 |
! |
19 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
20 |
!Fraction class methodsFor:'documentation'! |
88 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
213 | 25 |
All Rights Reserved |
88 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
Instances of Fraction represent fractional numbers consisting of |
|
39 |
a numerator and denominator. Both are themselfes arbitrary precision |
|
324 | 40 |
integers. Fractions are usually created by dividing Integers using / |
1295 | 41 |
(for exact division). |
42 |
||
1892 | 43 |
Mixed mode arithmetic: |
5322 | 44 |
fraction op fraction -> fraction |
45 |
fraction op fix -> fix; scale is fix's scale |
|
46 |
fraction op integer -> fraction |
|
47 |
fraction op float -> float |
|
1892 | 48 |
|
1295 | 49 |
[author:] |
5322 | 50 |
Claus Gittinger |
1556 | 51 |
|
52 |
[see also:] |
|
5322 | 53 |
Number |
54 |
Float Integer FixedPoint |
|
1295 | 55 |
" |
88 | 56 |
! ! |
1 | 57 |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
58 |
!Fraction class methodsFor:'initialization'! |
1 | 59 |
|
60 |
initialize |
|
302 | 61 |
FractionZero isNil ifTrue:[ |
62 |
FractionZero := self numerator:0 denominator:1. |
|
63 |
FractionOne := self numerator:1 denominator:1 |
|
64 |
] |
|
1 | 65 |
! ! |
66 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
67 |
!Fraction class methodsFor:'instance creation'! |
1 | 68 |
|
69 |
new |
|
70 |
"create and return a new fraction with value 0" |
|
71 |
||
54 | 72 |
^ self numerator:0 denominator:1 |
1 | 73 |
! |
74 |
||
75 |
numerator:num denominator:den |
|
76 |
"create and return a new fraction with numerator num and denominator den" |
|
77 |
||
2792 | 78 |
|newFraction| |
79 |
||
1 | 80 |
%{ /* NOCONTEXT */ |
369 | 81 |
|
13 | 82 |
/* this check allows subclassing .. */ |
1 | 83 |
if (self == Fraction) { |
5322 | 84 |
if (__bothSmallInteger(num, den)) { |
85 |
if (__CanDoQuickAlignedNew(sizeof(struct __Fraction))) { /* OBJECT ALLOCATION */ |
|
86 |
OBJ newFraction; |
|
87 |
int spc; |
|
1 | 88 |
|
5322 | 89 |
__qCheckedAlignedNew(newFraction, sizeof(struct __Fraction)); |
90 |
__InstPtr(newFraction)->o_class = self; |
|
91 |
if (__intVal(den) < 0) { |
|
92 |
__FractionInstPtr(newFraction)->f_numerator = __MKSMALLINT(- __intVal(num)); |
|
93 |
__FractionInstPtr(newFraction)->f_denominator = __MKSMALLINT(- __intVal(den)); |
|
94 |
} else { |
|
95 |
__FractionInstPtr(newFraction)->f_numerator = num; |
|
96 |
__FractionInstPtr(newFraction)->f_denominator = den; |
|
97 |
} |
|
98 |
if (num == __MKSMALLINT(1)) { |
|
99 |
RETURN ( newFraction ); |
|
100 |
} |
|
101 |
} |
|
102 |
} |
|
1 | 103 |
} |
2790 | 104 |
%}. |
2792 | 105 |
newFraction isNil ifTrue:[ |
5322 | 106 |
newFraction := self basicNew setNumerator:num denominator:den. |
2792 | 107 |
]. |
108 |
^ newFraction reduced |
|
1 | 109 |
! ! |
110 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
111 |
!Fraction class methodsFor:'constants'! |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
112 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
113 |
pi |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
114 |
"return the constant pi as Fraction" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
115 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
116 |
^ self |
5322 | 117 |
numerator: 31415926535897932384626434 |
118 |
denominator:10000000000000000000000000 |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
119 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
120 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
121 |
Fraction pi |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
122 |
Fraction pi asFloat |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
123 |
Float pi |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
124 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
125 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
126 |
"Modified: 5.11.1996 / 11:11:44 / cg" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
127 |
! |
701 | 128 |
|
129 |
unity |
|
1555 | 130 |
"return the neutral element for multiplication (1 / 1)" |
701 | 131 |
|
132 |
^ FractionOne |
|
1555 | 133 |
|
134 |
"Modified: 18.7.1996 / 12:26:06 / cg" |
|
701 | 135 |
! |
136 |
||
137 |
zero |
|
1555 | 138 |
"return the neutral element for addition (0 / 1)" |
701 | 139 |
|
140 |
^ FractionZero |
|
1555 | 141 |
|
142 |
"Modified: 18.7.1996 / 12:26:12 / cg" |
|
701 | 143 |
! ! |
144 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
145 |
!Fraction class methodsFor:'queries'! |
3 | 146 |
|
147 |
isBuiltInClass |
|
1264 | 148 |
"return true if this class is known by the run-time-system. |
149 |
Here, true is returned for myself, false for subclasses." |
|
3 | 150 |
|
151 |
^ self == Fraction |
|
1264 | 152 |
|
153 |
"Modified: 23.4.1996 / 15:59:10 / cg" |
|
3 | 154 |
! ! |
155 |
||
1 | 156 |
!Fraction methodsFor:'accessing'! |
157 |
||
158 |
denominator |
|
159 |
"return the denominator" |
|
160 |
||
161 |
^ denominator |
|
162 |
! |
|
163 |
||
701 | 164 |
numerator |
165 |
"return the numerator" |
|
1 | 166 |
|
701 | 167 |
^ numerator |
1 | 168 |
! ! |
169 |
||
170 |
!Fraction methodsFor:'arithmetic'! |
|
171 |
||
701 | 172 |
* aNumber |
173 |
"return the product of the receiver and the argument, aNumber" |
|
174 |
||
175 |
|n d| |
|
176 |
||
177 |
(aNumber isMemberOf:SmallInteger) ifTrue:[ |
|
5322 | 178 |
^ (self class numerator:(numerator * aNumber) |
179 |
denominator:denominator) |
|
701 | 180 |
]. |
181 |
aNumber isFraction ifTrue:[ |
|
5322 | 182 |
aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost |
183 |
n := numerator * aNumber numerator. |
|
184 |
d := denominator * aNumber denominator. |
|
185 |
^ (self class numerator:n denominator:d) |
|
186 |
] |
|
701 | 187 |
]. |
188 |
(aNumber isMemberOf:Float) ifTrue:[ |
|
5322 | 189 |
^ (numerator * aNumber) / denominator |
701 | 190 |
]. |
191 |
^ aNumber productFromFraction:self |
|
1892 | 192 |
|
2792 | 193 |
"Modified: 28.7.1997 / 19:09:23 / cg" |
701 | 194 |
! |
195 |
||
1 | 196 |
+ aNumber |
197 |
"return the sum of the receiver and the argument, aNumber" |
|
198 |
||
199 |
|n d| |
|
200 |
||
201 |
(aNumber isMemberOf:SmallInteger) ifTrue:[ |
|
5322 | 202 |
^ (self class numerator:(numerator + (denominator * aNumber)) |
203 |
denominator:denominator) |
|
1 | 204 |
]. |
259 | 205 |
aNumber isFraction ifTrue:[ |
5322 | 206 |
aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost |
207 |
n := aNumber numerator. |
|
208 |
d := aNumber denominator. |
|
1 | 209 |
|
5322 | 210 |
"save a multiplication if possible" |
211 |
denominator == d ifTrue:[ |
|
212 |
n := numerator + n |
|
213 |
] ifFalse:[ |
|
214 |
n := (numerator * d) + (n * denominator). |
|
215 |
d := denominator * d. |
|
216 |
]. |
|
217 |
^ (self class numerator:n denominator:d) |
|
218 |
] |
|
1 | 219 |
]. |
16 | 220 |
(aNumber isMemberOf:Float) ifTrue:[ |
5322 | 221 |
^ aNumber + (numerator asFloat / denominator asFloat) |
16 | 222 |
]. |
1 | 223 |
^ aNumber sumFromFraction:self |
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
224 |
|
2792 | 225 |
"Modified: 28.7.1997 / 19:09:16 / cg" |
1 | 226 |
! |
227 |
||
228 |
- aNumber |
|
229 |
"return the difference of the receiver and the argument, aNumber" |
|
230 |
||
231 |
|n d| |
|
232 |
||
233 |
(aNumber isMemberOf:SmallInteger) ifTrue:[ |
|
5322 | 234 |
^ (self class numerator:(numerator - (denominator * aNumber)) |
235 |
denominator:denominator) |
|
1 | 236 |
]. |
259 | 237 |
aNumber isFraction ifTrue:[ |
5322 | 238 |
aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost |
239 |
n := aNumber numerator. |
|
240 |
d := aNumber denominator. |
|
1 | 241 |
|
5322 | 242 |
"save a multiplication if possible" |
243 |
denominator == d ifTrue:[ |
|
244 |
n := numerator - n |
|
245 |
] ifFalse:[ |
|
246 |
n := (numerator * d) - (n * denominator). |
|
247 |
d := denominator * d |
|
248 |
]. |
|
249 |
^ (self class numerator:n denominator:d) |
|
250 |
] |
|
1 | 251 |
]. |
16 | 252 |
(aNumber isMemberOf:Float) ifTrue:[ |
5322 | 253 |
^ (numerator asFloat / denominator asFloat) - aNumber |
16 | 254 |
]. |
1 | 255 |
^ aNumber differenceFromFraction:self |
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
256 |
|
1892 | 257 |
" |
258 |
(1/3) - (1/9) |
|
259 |
(1/9) - (1/3) |
|
260 |
(999/1000) - (1/1000) |
|
261 |
(999/1000) - (1/1000000) |
|
262 |
(999000/1000000) - (1/1000000) |
|
263 |
" |
|
264 |
||
2792 | 265 |
"Modified: 28.7.1997 / 19:09:11 / cg" |
1 | 266 |
! |
267 |
||
268 |
/ aNumber |
|
269 |
"return the quotient of the receiver and the argument, aNumber" |
|
270 |
||
271 |
|n d| |
|
272 |
||
16 | 273 |
(aNumber isMemberOf:SmallInteger) ifTrue:[ |
5322 | 274 |
^ (self class numerator:numerator |
275 |
denominator:(denominator * aNumber)) |
|
16 | 276 |
]. |
259 | 277 |
aNumber isFraction ifTrue:[ |
5322 | 278 |
aNumber isFixedPoint ifFalse:[ "/ the value was corrent, but the scale is lost |
279 |
n := numerator * aNumber denominator. |
|
280 |
d := denominator * aNumber numerator. |
|
281 |
^ (self class numerator:n denominator:d) |
|
282 |
] |
|
1 | 283 |
]. |
16 | 284 |
(aNumber isMemberOf:Float) ifTrue:[ |
5322 | 285 |
^ numerator / (denominator * aNumber) |
16 | 286 |
]. |
1 | 287 |
^ aNumber quotientFromFraction:self |
1892 | 288 |
|
2792 | 289 |
"Modified: 28.7.1997 / 19:09:06 / cg" |
1 | 290 |
! |
291 |
||
292 |
// aNumber |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
293 |
"return the integer quotient of dividing the receiver by aNumber with |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
294 |
truncation towards negative infinity." |
1 | 295 |
|
296 |
^ (numerator * aNumber denominator) // (denominator * aNumber numerator) |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
297 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
298 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
299 |
0.5 // 1 |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
300 |
-0.5 // 1 |
3984
45a76e2f4236
Fix so that // and \\ truncate towards negative infinity and
Stefan Vogel <sv@exept.de>
parents:
3899
diff
changeset
|
301 |
(1/2) // 1 = 0 ifFalse:[self halt]. |
45a76e2f4236
Fix so that // and \\ truncate towards negative infinity and
Stefan Vogel <sv@exept.de>
parents:
3899
diff
changeset
|
302 |
(-1/2) // 1 = -1 ifFalse:[self halt]. |
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
303 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
304 |
|
3984
45a76e2f4236
Fix so that // and \\ truncate towards negative infinity and
Stefan Vogel <sv@exept.de>
parents:
3899
diff
changeset
|
305 |
"Modified: / 5.11.1996 / 11:47:14 / cg" |
45a76e2f4236
Fix so that // and \\ truncate towards negative infinity and
Stefan Vogel <sv@exept.de>
parents:
3899
diff
changeset
|
306 |
"Modified: / 13.2.1998 / 09:15:35 / stefan" |
1 | 307 |
! |
308 |
||
309 |
negated |
|
310 |
"optional - could use inherited method ..." |
|
311 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
312 |
^ self class |
5322 | 313 |
numerator:(numerator negated) |
314 |
denominator:denominator |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
315 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
316 |
"Modified: 5.11.1996 / 10:29:11 / cg" |
1 | 317 |
! |
318 |
||
319 |
reciprocal |
|
320 |
"optional - could use inherited method ..." |
|
321 |
||
322 |
numerator == 1 ifTrue:[^ denominator]. |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
323 |
^ self class |
5322 | 324 |
numerator:denominator |
325 |
denominator:numerator |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
326 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
327 |
"Modified: 5.11.1996 / 10:29:22 / cg" |
1 | 328 |
! ! |
329 |
||
701 | 330 |
!Fraction methodsFor:'coercing & converting'! |
331 |
||
1892 | 332 |
asFixedPoint |
333 |
"return the receiver as fixedPoint number. |
|
334 |
Q: what should the scale be here ?" |
|
335 |
||
336 |
^ FixedPoint numerator:numerator denominator:denominator scale:2 |
|
337 |
||
338 |
" |
|
339 |
(1/2) asFixedPoint |
|
340 |
" |
|
341 |
||
342 |
"Created: 5.11.1996 / 15:15:54 / cg" |
|
343 |
! |
|
344 |
||
2140 | 345 |
asFixedPoint:scale |
346 |
"return the receiver as fixedPoint number, with the given number |
|
347 |
of post-decimal-point digits." |
|
348 |
||
349 |
^ FixedPoint numerator:numerator denominator:denominator scale:scale |
|
350 |
||
351 |
" |
|
352 |
(1/2) asFixedPoint:2 |
|
353 |
(1/3) asFixedPoint:2 |
|
354 |
(1/3) asFixedPoint:5 |
|
355 |
(2/3) asFixedPoint:2 |
|
356 |
(2/3) asFixedPoint:5 |
|
357 |
" |
|
358 |
||
359 |
"Created: 5.11.1996 / 15:15:54 / cg" |
|
360 |
"Modified: 10.1.1997 / 19:54:50 / cg" |
|
361 |
! |
|
362 |
||
701 | 363 |
asFloat |
364 |
"return a float with (approximately) my value" |
|
365 |
||
366 |
^ (numerator asFloat) / (denominator asFloat) |
|
367 |
! |
|
1 | 368 |
|
701 | 369 |
asFraction |
370 |
"return the receiver as fraction - thats itself" |
|
371 |
||
372 |
^ self |
|
373 |
! |
|
374 |
||
375 |
asInteger |
|
376 |
"return an integer with my value - will usually truncate" |
|
1 | 377 |
|
378 |
^ numerator // denominator |
|
379 |
! |
|
380 |
||
701 | 381 |
asLargeInteger |
382 |
"return an integer with my value - will usually truncate" |
|
383 |
||
384 |
^ self asInteger asLargeInteger |
|
385 |
! |
|
386 |
||
1200 | 387 |
asShortFloat |
388 |
"return a shortFloat with (approximately) my value" |
|
389 |
||
390 |
^ (numerator asShortFloat) / (denominator asShortFloat) |
|
391 |
||
392 |
"Created: 17.4.1996 / 12:21:08 / cg" |
|
393 |
! |
|
394 |
||
701 | 395 |
coerce:aNumber |
396 |
"return aNumber converted into receivers type" |
|
397 |
||
398 |
^ aNumber asFraction |
|
399 |
! |
|
400 |
||
401 |
generality |
|
402 |
"return the generality value - see ArithmeticValue>>retry:coercing:" |
|
403 |
||
404 |
^ 60 |
|
405 |
! ! |
|
406 |
||
407 |
!Fraction methodsFor:'comparing'! |
|
408 |
||
409 |
< aNumber |
|
410 |
"return true if the receiver is less |
|
411 |
than aNumber, false otherwise." |
|
1 | 412 |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
413 |
|d n| |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
414 |
|
701 | 415 |
(aNumber isMemberOf:SmallInteger) ifTrue:[ |
5322 | 416 |
^ numerator < (denominator * aNumber) |
701 | 417 |
]. |
418 |
aNumber isFraction ifTrue:[ |
|
5322 | 419 |
d := aNumber denominator. |
420 |
n := aNumber numerator. |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
421 |
|
5322 | 422 |
"/ save a multiplication if possible |
423 |
d == denominator ifTrue:[ |
|
424 |
^ numerator < n |
|
425 |
]. |
|
426 |
^ (numerator * d) < (denominator * n) |
|
701 | 427 |
]. |
428 |
^ aNumber lessFromFraction:self |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
429 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
430 |
"Modified: 5.11.1996 / 10:30:52 / cg" |
701 | 431 |
! |
432 |
||
433 |
= aNumber |
|
434 |
"return true, if the argument represents the same numeric value |
|
435 |
as the receiver, false otherwise" |
|
436 |
||
437 |
(aNumber isMemberOf:SmallInteger) ifTrue:[ |
|
5322 | 438 |
(denominator = 1) ifFalse:[^ false]. |
439 |
^ numerator = aNumber |
|
1 | 440 |
]. |
701 | 441 |
aNumber isFraction ifTrue:[ |
5322 | 442 |
(numerator = aNumber numerator) ifFalse:[^ false]. |
443 |
^ denominator = aNumber denominator |
|
3631
26a44b284912
handle largeInteger case in Fraction =
Claus Gittinger <cg@exept.de>
parents:
2894
diff
changeset
|
444 |
]. |
26a44b284912
handle largeInteger case in Fraction =
Claus Gittinger <cg@exept.de>
parents:
2894
diff
changeset
|
445 |
(aNumber isInteger) ifTrue:[ |
5322 | 446 |
(denominator = 1) ifFalse:[^ false]. |
447 |
^ numerator = aNumber |
|
701 | 448 |
]. |
449 |
^ self retry:#= coercing:aNumber |
|
3631
26a44b284912
handle largeInteger case in Fraction =
Claus Gittinger <cg@exept.de>
parents:
2894
diff
changeset
|
450 |
|
26a44b284912
handle largeInteger case in Fraction =
Claus Gittinger <cg@exept.de>
parents:
2894
diff
changeset
|
451 |
"Modified: / 7.7.1998 / 17:17:07 / cg" |
701 | 452 |
! |
453 |
||
454 |
> aNumber |
|
455 |
"return true if the receiver is greater |
|
456 |
than aNumber, false otherwise." |
|
457 |
"optional - could use inherited method ..." |
|
458 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
459 |
|d n| |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
460 |
|
701 | 461 |
(aNumber isMemberOf:SmallInteger) ifTrue:[ |
5322 | 462 |
^ numerator > (denominator * aNumber) |
701 | 463 |
]. |
464 |
aNumber isFraction ifTrue:[ |
|
5322 | 465 |
d := aNumber denominator. |
466 |
n := aNumber numerator. |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
467 |
|
5322 | 468 |
"/ save a multiplication if possible |
469 |
d == denominator ifTrue:[ |
|
470 |
^ numerator > n |
|
471 |
]. |
|
472 |
^ (numerator * d) > (denominator * n) |
|
701 | 473 |
]. |
474 |
^ self retry:#> coercing:aNumber |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
475 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
476 |
"Modified: 5.11.1996 / 10:31:28 / cg" |
4593 | 477 |
! |
478 |
||
479 |
hash |
|
480 |
"return a number for hashing; redefined, since fractions compare |
|
481 |
by numeric value (i.e. (9/3) = 3), therefore (9/3) hash must be the same |
|
4594
eb09f567a3bc
float, shortFloat and fraction all hash alike
Claus Gittinger <cg@exept.de>
parents:
4593
diff
changeset
|
482 |
as 3 hash." |
4593 | 483 |
|
484 |
(denominator = 1) ifTrue:[^ numerator hash]. |
|
485 |
||
4594
eb09f567a3bc
float, shortFloat and fraction all hash alike
Claus Gittinger <cg@exept.de>
parents:
4593
diff
changeset
|
486 |
^ self asFloat hash |
4593 | 487 |
|
488 |
" |
|
489 |
3 hash |
|
490 |
(9/3) hash |
|
491 |
3.0 hash |
|
492 |
(1/2) hash |
|
4594
eb09f567a3bc
float, shortFloat and fraction all hash alike
Claus Gittinger <cg@exept.de>
parents:
4593
diff
changeset
|
493 |
(1/4) hash |
4593 | 494 |
0.0 hash |
495 |
0.5 hash |
|
496 |
0.25 hash |
|
497 |
0.4 hash |
|
498 |
" |
|
1 | 499 |
! ! |
500 |
||
501 |
!Fraction methodsFor:'double dispatching'! |
|
502 |
||
701 | 503 |
differenceFromFloat:aFloat |
504 |
"sent when a float does not know how to subtract the receiver, a fraction" |
|
1 | 505 |
|
701 | 506 |
^ (aFloat * denominator - numerator) / denominator |
1 | 507 |
! |
508 |
||
509 |
differenceFromInteger:anInteger |
|
213 | 510 |
"sent when an integer does not know how to subtract the receiver, a fraction" |
1 | 511 |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
512 |
^ (self class |
5322 | 513 |
numerator:((anInteger * denominator) - numerator) |
514 |
denominator:denominator) |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
515 |
|
2792 | 516 |
"Modified: 28.7.1997 / 19:08:53 / cg" |
1 | 517 |
! |
518 |
||
701 | 519 |
lessFromInteger:anInteger |
520 |
"sent when an integer does not know how to compare to the receiver, a fraction" |
|
521 |
||
522 |
^ (denominator * anInteger) < numerator |
|
523 |
! |
|
524 |
||
525 |
productFromFloat:aFloat |
|
526 |
"sent when a float does not know how to multiply the receiver, a fraction" |
|
527 |
||
528 |
^ aFloat * numerator / denominator |
|
529 |
! |
|
530 |
||
1 | 531 |
productFromInteger:anInteger |
213 | 532 |
"sent when an integer does not know how to multiply the receiver, a fraction" |
1 | 533 |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
534 |
^ (self class |
5322 | 535 |
numerator:(anInteger * numerator) |
536 |
denominator:denominator) |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
537 |
|
2792 | 538 |
"Modified: 28.7.1997 / 19:06:22 / cg" |
1 | 539 |
! |
540 |
||
701 | 541 |
quotientFromFloat:aFloat |
542 |
"sent when a float does not know how to divide by the receiver, a fraction" |
|
543 |
||
544 |
^ (aFloat * denominator) / numerator |
|
545 |
! |
|
546 |
||
324 | 547 |
quotientFromInteger:anInteger |
548 |
"sent when an integer does not know how to divide by the receiver, a fraction" |
|
549 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
550 |
^ (self class |
5322 | 551 |
numerator:(anInteger * denominator) |
552 |
denominator:numerator) |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
553 |
|
2792 | 554 |
"Modified: 28.7.1997 / 19:08:46 / cg" |
324 | 555 |
! |
556 |
||
1 | 557 |
sumFromFloat:aFloat |
213 | 558 |
"sent when a float does not know how to add the receiver, a fraction" |
1 | 559 |
|
560 |
^ (aFloat * denominator + numerator) / denominator |
|
561 |
! |
|
562 |
||
701 | 563 |
sumFromInteger:anInteger |
564 |
"sent when an integer does not know how to add the receiver, a fraction" |
|
1 | 565 |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
566 |
^ (self class |
5322 | 567 |
numerator:(numerator + (anInteger * denominator)) |
568 |
denominator:denominator) |
|
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
569 |
|
2792 | 570 |
"Modified: 28.7.1997 / 19:08:40 / cg" |
1 | 571 |
! ! |
572 |
||
92 | 573 |
!Fraction methodsFor:'printing & storing'! |
1 | 574 |
|
54 | 575 |
printOn:aStream |
576 |
"append a printed representation of the receiver to the |
|
577 |
argument, aStream" |
|
578 |
||
579 |
aStream nextPut:$(. |
|
580 |
numerator printOn:aStream. |
|
581 |
aStream nextPut:$/. |
|
582 |
denominator printOn:aStream. |
|
583 |
aStream nextPut:$) |
|
1 | 584 |
! ! |
701 | 585 |
|
586 |
!Fraction methodsFor:'private'! |
|
587 |
||
588 |
reduced |
|
589 |
"reduce the receiver" |
|
590 |
||
2790 | 591 |
|gcd den| |
701 | 592 |
|
2790 | 593 |
den := denominator. |
594 |
den < 0 ifTrue:[ |
|
5322 | 595 |
numerator := numerator negated. |
596 |
den := denominator := den negated. |
|
2789
e3e8707d26b4
make certain, that denominator is positive (in #reduce)
Claus Gittinger <cg@exept.de>
parents:
2140
diff
changeset
|
597 |
]. |
e3e8707d26b4
make certain, that denominator is positive (in #reduce)
Claus Gittinger <cg@exept.de>
parents:
2140
diff
changeset
|
598 |
|
2790 | 599 |
den == 1 ifTrue:[^ numerator]. |
701 | 600 |
numerator == 1 ifTrue:[^ self]. |
601 |
numerator == 0 ifTrue:[^ 0]. |
|
602 |
||
2790 | 603 |
gcd := numerator gcd:den. |
604 |
(gcd ~~ 1) ifTrue:[ |
|
5322 | 605 |
numerator := numerator // gcd. |
606 |
denominator := den := den // gcd. |
|
607 |
den < 0 ifTrue:[ |
|
608 |
numerator := numerator negated. |
|
609 |
den := denominator := den negated. |
|
610 |
]. |
|
611 |
(den == 1) ifTrue:[^ numerator]. |
|
701 | 612 |
]. |
613 |
^ self |
|
614 |
! |
|
615 |
||
616 |
setNumerator:num denominator:den |
|
617 |
"set both numerator and denominator" |
|
618 |
||
619 |
numerator := num. |
|
620 |
denominator := den |
|
621 |
! ! |
|
622 |
||
623 |
!Fraction methodsFor:'queries'! |
|
624 |
||
625 |
isFraction |
|
626 |
"return true, if the receiver is some kind of fraction; |
|
627 |
true is returned here - the method is redefined from Object." |
|
628 |
||
629 |
^ true |
|
630 |
! ! |
|
631 |
||
632 |
!Fraction methodsFor:'testing'! |
|
633 |
||
4658
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
634 |
isLiteral |
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
635 |
"return true, if the receiver can be used as a literal constant in ST syntax |
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
636 |
(i.e. can be used in constant arrays)" |
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
637 |
|
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
638 |
^ true |
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
639 |
|
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
640 |
! |
1a74754fbe91
moved isLiteral (complex and FixedPoint are not)
Claus Gittinger <cg@exept.de>
parents:
4594
diff
changeset
|
641 |
|
701 | 642 |
negative |
643 |
"return true if the receiver is negative" |
|
644 |
||
645 |
(numerator < 0) ifTrue:[ |
|
646 |
^ (denominator < 0) not |
|
647 |
]. |
|
648 |
^ (denominator < 0) |
|
649 |
! ! |
|
650 |
||
651 |
!Fraction methodsFor:'truncation and rounding'! |
|
652 |
||
3899
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
653 |
fractionPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
654 |
"extract the after-decimal fraction part." |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
655 |
|
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
656 |
numerator < denominator ifTrue:[ |
5322 | 657 |
^ self |
3899
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
658 |
]. |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
659 |
^ super fractionPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
660 |
|
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
661 |
" |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
662 |
(3/2) fractionPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
663 |
(2/3) fractionPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
664 |
((3/2)*(15/4)) fractionPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
665 |
((2/3)*(4/15)) fractionPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
666 |
" |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
667 |
|
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
668 |
"Modified: / 28.10.1998 / 17:15:11 / cg" |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
669 |
! |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
670 |
|
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
671 |
integerPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
672 |
"extract the pre-decimal integer part." |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
673 |
|
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
674 |
numerator < denominator ifTrue:[ |
5322 | 675 |
^ 0 |
3899
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
676 |
]. |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
677 |
^ super integerPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
678 |
|
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
679 |
" |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
680 |
(3/2) integerPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
681 |
(2/3) integerPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
682 |
((3/2)*(15/4)) integerPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
683 |
((2/3)*(4/15)) integerPart |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
684 |
" |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
685 |
|
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
686 |
"Modified: / 28.10.1998 / 17:16:10 / cg" |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
687 |
! |
aa9b50cdfced
added #fractionPart and #integerPart
Claus Gittinger <cg@exept.de>
parents:
3631
diff
changeset
|
688 |
|
701 | 689 |
rounded |
690 |
"return the receiver rounded to the nearest integer as integer" |
|
691 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
692 |
"/ mhmh - what about -(1/2) |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
693 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
694 |
|t| |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
695 |
|
701 | 696 |
self negative ifTrue:[ |
5322 | 697 |
t := self - (1/2) |
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
698 |
] ifFalse:[ |
5322 | 699 |
t := self + (1/2) |
701 | 700 |
]. |
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
701 |
^ t truncated. |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
702 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
703 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
704 |
(1/3) rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
705 |
(1/3) negated rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
706 |
(1/2) rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
707 |
(1/2) negated rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
708 |
0.5 rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
709 |
-0.5 rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
710 |
(2/3) rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
711 |
(2/3) negated rounded |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
712 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
713 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
714 |
"Modified: 5.11.1996 / 11:32:32 / cg" |
701 | 715 |
! |
716 |
||
717 |
truncated |
|
718 |
"return the receiver truncated towards zero as Integer" |
|
719 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
720 |
^ numerator quo: denominator |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
721 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
722 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
723 |
(3/2) truncated |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
724 |
(3/2) negated truncated |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
725 |
" |
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
726 |
|
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
727 |
"Modified: 5.11.1996 / 12:18:46 / cg" |
701 | 728 |
! ! |
729 |
||
1878
5615af5e7f47
fixed truncated & rounded for negative fractions
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
730 |
!Fraction class methodsFor:'documentation'! |
701 | 731 |
|
732 |
version |
|
5322 | 733 |
^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.48 2000-03-24 11:54:39 cg Exp $' |
701 | 734 |
! ! |
735 |
Fraction initialize! |