Re: 1e-4 printing bug

Thomas Worthington <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <[email protected]>
Derek,
   Are you saying that when I type

1e-4 asFraction

and get

1/10000

that's wrong, then?

It seems pretty obvious that if asFraction returns the right answer and asExactFraction returns the wrong answer, then there is a bug in the latter and not the former. Starting with the same input, there is no reason why they should return different answers in this particular case.

It may simply be a case of asExactFraction being mis-named. The comment in the code even uses the word "approximation".

More strangeness:

(10 raisedTo: -4) asExactFraction
1/10000

(10 raisedTo: -4) asFloat
0.0001

1e-4
0.00001


So, I think we can firmly state that the problem here is not in the output routines. It may in fact be the input routine (i.e., the parser).

Thomas


Derek Zhou writes:

> Thomas Worthington writes:
>
>> If 13743895/137438953472 == 1/10000 then 137438953472/13743895 == 10000, which it clearly does not, so it seem to me still to be an underlying issue with asExactFraction or some related method.
>
> 1e-4 is a floating point number which is not the same as 1/10000 the
> fraction.
>
> _______________________________________________
> help-smalltalk mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.