hi guys
what your take on http://code.google.com/p/pharo/issues/detail?id=2968 Stef "The same value in a LargePositiveInteger and a SmallInteger will not compare properly. The same value in two LargePositiveIntegers will not compare properly, if their byte sizes are different. I think the problem is in Integer>>#digitCompare: It gives incorrect results if the digitLengths are different between receiver and arg. This bug cost me about a day to find and fix. Maybe it has been addressed in a newer image/vm but I thought I would offer my fix to save someone else some time if it hasn't been dealt with yet. (I searched all issues) Pharo image: Pharo1.0-10508-rc2dev10.01.2.image Pharo core version: Pharo-1.0-10508-rc2 Latest update: #10508 Virtual machine used: <Squeak 4.2.5b1 - Mac OSX> Steps to reproduce: 1. (Integer new: 6 neg: false) = (Integer new: 8 neg: false) "0 = 0 should return true" 2. | int | int := Integer new: 6 neg: false. int digitAt: 1 put: 6. ^int = 6 "6 = 6 should return true"" _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
my take is normalize integers after manipulating with them using digitAt:put:
because if not, then you can't rely on size when comparing numbers, and comparison will become much slower, since you forced to always compare contents, regardless that size is different. On 18 September 2010 11:14, Stéphane Ducasse <[hidden email]> wrote: > hi guys > > what your take on > > http://code.google.com/p/pharo/issues/detail?id=2968 > > Stef > > "The same value in a LargePositiveInteger and a SmallInteger will not compare properly. The same value in two LargePositiveIntegers will not compare properly, if their byte sizes are different. I think the problem is in Integer>>#digitCompare: It gives incorrect results if the digitLengths are different between receiver and arg. This bug cost me about a day to find and fix. Maybe it has been addressed in a newer image/vm but I thought I would offer my fix to save someone else some time if it hasn't been dealt with yet. (I searched all issues) > > Pharo image: Pharo1.0-10508-rc2dev10.01.2.image > Pharo core version: Pharo-1.0-10508-rc2 Latest update: #10508 > Virtual machine used: <Squeak 4.2.5b1 - Mac OSX> > > > Steps to reproduce: > 1. > > (Integer new: 6 neg: false) = (Integer new: 8 neg: false) "0 = 0 should return true" > > > 2. > > | int | > int := Integer new: 6 neg: false. > int digitAt: 1 put: 6. > ^int = 6 "6 = 6 should return true"" > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Best regards, Igor Stasenko AKA sig. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
yes I think so too.
On Sep 18, 2010, at 10:56 AM, Igor Stasenko wrote: > my take is normalize integers after manipulating with them using digitAt:put: > because if not, then you can't rely on size when comparing numbers, > and comparison will become much slower, since you forced to always > compare contents, > regardless that size is different. > > On 18 September 2010 11:14, Stéphane Ducasse <[hidden email]> wrote: >> hi guys >> >> what your take on >> >> http://code.google.com/p/pharo/issues/detail?id=2968 >> >> Stef >> >> "The same value in a LargePositiveInteger and a SmallInteger will not compare properly. The same value in two LargePositiveIntegers will not compare properly, if their byte sizes are different. I think the problem is in Integer>>#digitCompare: It gives incorrect results if the digitLengths are different between receiver and arg. This bug cost me about a day to find and fix. Maybe it has been addressed in a newer image/vm but I thought I would offer my fix to save someone else some time if it hasn't been dealt with yet. (I searched all issues) >> >> Pharo image: Pharo1.0-10508-rc2dev10.01.2.image >> Pharo core version: Pharo-1.0-10508-rc2 Latest update: #10508 >> Virtual machine used: <Squeak 4.2.5b1 - Mac OSX> >> >> >> Steps to reproduce: >> 1. >> >> (Integer new: 6 neg: false) = (Integer new: 8 neg: false) "0 = 0 should return true" >> >> >> 2. >> >> | int | >> int := Integer new: 6 neg: false. >> int digitAt: 1 put: 6. >> ^int = 6 "6 = 6 should return true"" >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > > -- > Best regards, > Igor Stasenko AKA sig. > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |