Re: [Help-smalltalk] Bug, float is printed wrongly
The following seem to be related. 1/5000 is 2e-4; 1/1 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/1 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/1 to 13743895/137438953472, which is just less than 1/1, so the floor operation shifts it to 1/10 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.1 > st> > > > > > > On Sat, Aug 11, 2018 at 1:05 PM Tommy Pettersson 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.1 >> st> x+x >> 0.0002 >> >> Kind regards, >> Tommy >> >> ___ >> help-smalltalk mailing list >> help-smalltalk@gnu.org >> https://lists.gnu.org/mailman/listinfo/help-smalltalk >> > ___ > help-smalltalk mailing list > help-smalltalk@gnu.org > https://lists.gnu.org/mailman/listinfo/help-smalltalk ___ help-smalltalk mailing list help-smalltalk@gnu.org https://lists.gnu.org/mailman/listinfo/help-smalltalk
Re: [Help-smalltalk] Bug, float is printed wrongly
$ 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.1 st> On Sat, Aug 11, 2018 at 1:05 PM Tommy Pettersson 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.1 > st> x+x > 0.0002 > > Kind regards, > Tommy > > ___ > help-smalltalk mailing list > help-smalltalk@gnu.org > https://lists.gnu.org/mailman/listinfo/help-smalltalk > ___ help-smalltalk mailing list help-smalltalk@gnu.org https://lists.gnu.org/mailman/listinfo/help-smalltalk
Re: [Help-smalltalk] Bug, float is printed wrongly
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 help-smalltalk@gnu.org https://lists.gnu.org/mailman/listinfo/help-smalltalk
Re: [Help-smalltalk] Bug, float is printed wrongly
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 (s...@gnu.org) and Paolo Bonzini (bonz...@gnu.org) 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 signature.asc Description: OpenPGP digital signature ___ help-smalltalk mailing list help-smalltalk@gnu.org https://lists.gnu.org/mailman/listinfo/help-smalltalk