help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] 1e-4 printing bug


From: Thomas Worthington
Subject: Re: [Help-smalltalk] 1e-4 printing bug
Date: Thu, 18 Apr 2019 14:40:41 +0100
User-agent: mu4e 1.1.0; emacs 26.1

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
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-smalltalk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]