[BUG] Fraction>>asFloat returns infinity if numerator and denominator both very large
ivan.tomek at acadiau.ca
Tue Oct 10 16:15:28 UTC 2000
> At 7:39 -0700 10/9/00, Martin McClure wrote:
> >I ran into this surprising result last night:
> > aFraction rounded
> >returned a reasonable value (318, IIRC) but
> > aFraction asFloat
> >returned Infinity.
> >A test case:
> > ((10 raisedToInteger: 309) + 1 / (10 raisedToInteger: 309)) rounded
> >returns 1, which seems correct, but
> > ((10 raisedToInteger: 309) + 1 / (10 raisedToInteger: 309)) asFloat
> >returns Infinity, which does not seem correct. I expect to get exactly 1.0 in
> >this case, since that is the Float value that most closely approximates the
> >Fraction's value.
That's what you get in VisualWorks. The following is my observation in VW.
> (David N. Smith)
> I think I disagree. The first example is done entirely in integers and answers
> The second becomes two Infinites divided by each other as they are being
> converted to float, which cannot answer a number no matter what.
The second test work the same way as the first, only the final conversion of the
Fraction is different.
I don't think that any infinities are involved - just LargePositiveIntegers.
Jodrey School of Computer Science
Nova Scotia, Canada
fax: (902) 585-1067
voice: (902) 585-1467
e-mail: ivan.tomek at acadiau.ca
More information about the Squeak-dev