Bug, float is printed wrongly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug, float is printed wrongly

Tommy Pettersson
Hi,

The float 1e-4 gets too many zeros when printed. This happens on version
3.2.5 and on the current master branch at git://git.sv.gnu.org/smalltalk.git,
on both 32-bit and 64-bit.

Example:
st> x := 1e-4
0.00001
st> x+x
0.0002

Kind regards,
Tommy

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Bug, float is printed wrongly

bill-auger
on debian 9:

$ gst
st> x := 1e-4
Object: 1 error: The program attempted to divide a number by zero
ZeroDivide(Exception)>>signal (ExcHandling.st:254)
SmallInteger(Number)>>zeroDivide (SysExcept.st:1426)
Fraction>>setNumerator:setDenominator: (Fraction.st:485)
Fraction class>>numerator:denominator: (Fraction.st:66)
Fraction>>- (Fraction.st:151)
FloatE(Float)>>printOn:special: (Float.st:533)
FloatE(Float)>>printOn: (Float.st:436)
FloatE(Object)>>printString (Object.st:534)
FloatE(Object)>>printNl (Object.st:571)


$ gst --version
GNU Smalltalk version 3.2.5
Copyright 2009 Free Software Foundation, Inc.
Written by Steve Byrne ([hidden email]) and Paolo Bonzini ([hidden email])

GNU Smalltalk comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Smalltalk under the terms of the
GNU General Public License.  For more information, see the file named
COPYING.

Using default kernel path: /usr/share/gnu-smalltalk/kernel
Using default image path: /usr/lib/gnu-smalltalk


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Bug, float is printed wrongly

Tommy Pettersson
Hi Bill,

I think the ZeroDivide exception is unrelated, and caused by your gst being
compiled with option -pie (the default in many distros). If so, you would
get the same exception for 0.05 and many other numbers. Try compiling gst
with -no-pie to see if the exception goes away.

/Tommy

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Bug, float is printed wrongly

Blake McBride-2
In reply to this post by Tommy Pettersson
$ gst --version
GNU Smalltalk version 3.2.92-dfe4b56
$ gst
GNU Smalltalk ready

st> 1e1
10.0
st> 1e0
1.0
st> 1e-1
0.1
st> 1e-2
0.01
st> 1e-3
0.001
st> 1e-4
0.00001
st>





On Sat, Aug 11, 2018 at 1:05 PM Tommy Pettersson <[hidden email]> wrote:

> Hi,
>
> The float 1e-4 gets too many zeros when printed. This happens on version
> 3.2.5 and on the current master branch at git://
> git.sv.gnu.org/smalltalk.git,
> on both 32-bit and 64-bit.
>
> Example:
> st> x := 1e-4
> 0.00001
> st> x+x
> 0.0002
>
> Kind regards,
> Tommy
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk
>
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

'ZeroDivide' error using debian package

bill-auger
In reply to this post by Tommy Pettersson
On 08/11/2018 04:50 PM, Tommy Pettersson wrote:

> On 08/11/2018 04:25 PM, bill-auger wrote:
> > on debian 9:
> >
> > $ gst
> > st> x := 1e-4
> > Object: 1 error: The program attempted to divide a number by zero
> > ZeroDivide(Exception)>>signal (ExcHandling.st:254)
> > SmallInteger(Number)>>zeroDivide (SysExcept.st:1426)
> > Fraction>>setNumerator:setDenominator: (Fraction.st:485)
> > Fraction class>>numerator:denominator: (Fraction.st:66)
> > Fraction>>- (Fraction.st:151)
> > FloatE(Float)>>printOn:special: (Float.st:533)
> > FloatE(Float)>>printOn: (Float.st:436)
> > FloatE(Object)>>printString (Object.st:534)
> > FloatE(Object)>>printNl (Object.st:571)
> >
> >
> > $ gst --version
> > GNU Smalltalk version 3.2.5
>
>> I think the ZeroDivide exception is unrelated, and caused by your gst
being> compiled with option -pie (the default in many distros). If so,
you would> get the same exception for 0.05 and many other numbers. Try
compiling gst> with -no-pie to see if the exception goes away.> > /Tommy

yes - i see now it is a different problem - and 0.05 does give the same
'ZeroDivide' error

to be clear, my original result with the 'ZeroDivide' error was using
the official debian package - i do not see the 'ZeroDivide' problem when
compiling myself from git - but it is not clear that the -pie flag is
the cause - i will CC to the debian packaging team "Debian GNU Smalltalk
maintainers" as the deb package indicates; although i see it is (since
April 2018) listed as an inactive mailing list - if no response i will
file a bug report against the package

`gcc -v` and `g++ -v` both show --enable-default-pie; but i can not
expose the 'ZeroDivide' problem compiling myself - compiling with all of
the following flags produce the same (non-error) result for 1e-4 and 0.05:

$ make CFLAGS='-no-pie'
$ make CFLAGS='-pie'
$ make

$ /usr/local/bin/gst
GNU Smalltalk ready

st> 0.05
0.05


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Bug, float is printed wrongly

Thomas Worthington
In reply to this post by Blake McBride-2
The following seem to be related. 1/5000 is 2e-4; 1/10000 is 1e-4 and so
all these lines should give the same result of -4. The conversion
"asExactFraction", which is called from the Float.st version of
floorLog:, causes a -5 answer which is wrong:


st>gst --version
GNU Smalltalk version 3.2.92-b033a21c

st> 1/5000 floorLog:10
-4
st> 1/10000 floorLog:10
-4
st> 1e-4 asExactFraction
13743895/137438953472
st> (1e-4 asExactFraction) floorLog:10
-5
st> (2e-4 asExactFraction) floorLog:10
-4


The problem is caused by converting 1/10000 to 13743895/137438953472,
which is just less than 1/10000, so the floor operation shifts it to
1/100000 and gets -5.

Thomas Worthington



Blake McBride writes:

> $ gst --version
> GNU Smalltalk version 3.2.92-dfe4b56
> $ gst
> GNU Smalltalk ready
>
> st> 1e1
> 10.0
> st> 1e0
> 1.0
> st> 1e-1
> 0.1
> st> 1e-2
> 0.01
> st> 1e-3
> 0.001
> st> 1e-4
> 0.00001
> st>
>
>
>
>
>
> On Sat, Aug 11, 2018 at 1:05 PM Tommy Pettersson <[hidden email]> wrote:
>
>> Hi,
>>
>> The float 1e-4 gets too many zeros when printed. This happens on version
>> 3.2.5 and on the current master branch at git://
>> git.sv.gnu.org/smalltalk.git,
>> on both 32-bit and 64-bit.
>>
>> Example:
>> st> x := 1e-4
>> 0.00001
>> st> x+x
>> 0.0002
>>
>> Kind regards,
>> Tommy
>>
>> _______________________________________________
>> help-smalltalk mailing list
>> [hidden email]
>> https://lists.gnu.org/mailman/listinfo/help-smalltalk
>>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: 'ZeroDivide' error using debian package

Holger Freyther
In reply to this post by bill-auger


> On 12. Aug 2018, at 00:31, bill-auger <[hidden email]> wrote:
>

Hi,


> `gcc -v` and `g++ -v` both show --enable-default-pie; but i can not
> expose the 'ZeroDivide' problem compiling myself - compiling with all of
> the following flags produce the same (non-error) result for 1e-4 and 0.05:


you might trigger known undefined behavior in the multiplication path.

Could you try http://git.savannah.gnu.org/cgit/smalltalk.git/commit/?id=72ada189aba0283c551ead16635c1983968080b8?



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: 'ZeroDivide' error using debian package

bill-auger
On 08/13/2018 04:48 AM, Holger Freyther wrote:
> you might trigger known undefined behavior in the multiplication path.
>
> Could you try http://git.savannah.gnu.org/cgit/smalltalk.git/commit/?id=72ada189aba0283c551ead16635c1983968080b8?

im not sure what result you thought i may get - were you suspecting that
building from that commit would expose the 'ZeroDivde' error? - it did
not - the results are exactly the same including the order-of-magnitude
bug for 1e-4


  $ gst --version
  GNU Smalltalk version 3.2.92-72ada189


  $ gst
  GNU Smalltalk ready

  st> 0.05
  0.05
  st> 1e-4
  0.00001
  st> 1e-3
  0.001


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 'ZeroDivide' error using debian package

bill-auger
In reply to this post by bill-auger
BTW - i discovered that the debian smalltalk packaging team seems to have dissolved - i have posted a bug report[1] against the debian package regarding the 'ZeroDivde' error; but it is not clear that the package has any maintainer currently

a few months ago, debian migrated all mailing lists to a new service; so the email address in the CC (from the deb package) is invalid - the debian smalltalk packaging team did not claim a new mailing list - debian policy considers that a "release critical" bug; so for that reason, the 'gnu-smalltalk' debian package is currently not fit for release and will be dropped from debian 10 unless one of the previous maintainer tends to it or a new maintainer is found


[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=906149

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 'ZeroDivide' error using debian package

Tommy Pettersson
In reply to this post by Holger Freyther
On Mon, Aug 13, 2018 at 09:48:30AM +0100, Holger Freyther wrote:
> Could you try http://git.savannah.gnu.org/cgit/smalltalk.git/commit/?id=72ada189aba0283c551ead16635c1983968080b8?

I have used system libsigsegv libffi and libltdl, because this is what the
Gentoo distribution uses, and their gnu-smalltalk package has the
ZeroDivide Exception problem (I have filed a bug report at
bugs.gentoo.org).

For 3.2.5 adding -no-pie solves fixes the problem.

For 72ada189aba0283c551ead16635c1983968080b8 I don't get the ZeroDivide exception.



; git checkout tags/3.2.5
; ./configure --with-system-libsigsegv --with-system-libffi --with-system-libltdl --with-readline --with-gmp --without-tcl
; make
; ./gst
st> 0.05
Object: 1 error: The program attempted to divide a number by zero                                            
ZeroDivide(Exception)>>signal (ExcHandling.st:254)                                                          
SmallInteger(Number)>>zeroDivide (SysExcept.st:1426)                                                        
Fraction>>setNumerator:setDenominator: (Fraction.st:485)                                                    
Fraction class>>numerator:denominator: (Fraction.st:66)                                                      
Fraction>>- (Fraction.st:151)                                                                                
FloatD(Float)>>printOn:special: (Float.st:533)                                                              
FloatD(Float)>>printOn: (Float.st:436)                                                                      
FloatD(Object)>>printString (Object.st:534)                                                                  
FloatD(Object)>>printNl (Object.st:571)                                                                      


; git checkout tags/3.2.5
; export CFLAGS='-no-pie'
; export LDFLAGS='-no-pie'
; ./configure --with-system-libsigsegv --with-system-libffi --with-system-libltdl --with-readline --with-gmp --without-tcl
; make
; ./gst
st> 0.05
0.05


; git checkout 72ada189aba0283c551ead16635c1983968080b8
; ./configure --with-system-libsigsegv --with-system-libffi --with-system-libltdl --with-readline --with-gmp --without-tcl
; make
; ./gst
st> 0.05
0.05


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk