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: Sun, 31 Mar 2019 19:05:19 +0100
User-agent: mu4e 1.1.0; emacs 26.1

Derek,
   The issue is an underlying one in how numbers are converted to exact 
fractions as part of the printing process; the problem needs to be addressed 
there since it will be affecting more than just printing.

Thomas

Derek Zhou writes:

> list:
>
> Previously in the list someone reported a bug in float printing:
>
> st> 1e-4
> 0.00001
>
> There is a bug in Float printing which I attached a patch. the variable
> allNines should really mean all nines except the last one, so if the
> last one round up, which  may not be 9 itself,  still can cause the
> whole digits round up and eat a leading zero in printing.
>
> Here is a patch to fix:
>
> diff --git a/kernel/Float.st b/kernel/Float.st
> index 3714f08..7e8e012 100644
> --- a/kernel/Float.st
> +++ b/kernel/Float.st
> @@ -527,10 +527,11 @@ if the hardware supports it.'>
>       allNines := true.
>          sameDown := true.
>          sameUp := true.
> +     digit := 9.
>
> -        [digit := num // weight.
> +        [allNines := allNines and: [digit = 9].
> +     digit := num // weight.
>          num := num \\ weight.
> -     allNines := allNines and: [digit = 9].
>          sameDown := sameDown and: [num >= eps].
>          sameUp := sameUp and: [num < (weight - eps)].
>       digits := digits * 10 + digit.
> _______________________________________________
> 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]