On Jan 18, 2012, at 12:49 45PM, Henrik Johansen wrote: > > On Jan 18, 2012, at 12:44 58PM, Mariano Martinez Peck wrote: > >> >> >> On Wed, Jan 18, 2012 at 12:25 PM, Henrik Johansen >> <henrik.s.johan...@veloxit.no> wrote: >> >> On Jan 18, 2012, at 12:14 47PM, Mariano Martinez Peck wrote: >> >> > Well....it seems I found the problem. And in fact, it has alredy been >> > solved by Levente in Squeak...I waste so many hours...and the fix was >> > there.. >> > >> > So, can you try changing to >> > >> > sizeFor: numberOfElements >> > "Return the minimum capacity of a dictionary that can hold >> > numberOfElements elements. At least 25% of the array must be empty and the >> > return value must be a power of 2." >> > >> > ^(numberOfElements * 4 // 3) asLargerPowerOfTwo max: 1 >> > >> > >> > And see if it works? it works here… >> >> It should not be necessary. >> The real bug is that Integer >> isPowerOfTwo does not check for the edge >> case: >> >> 0 isPowerOfTwo true >> >> A small fix: >> >> Integer >> #isPowerOfTwo >> "Return true if the receiver is an integral power of two." >> ^ self ~= 0 and: [(self bitAnd: self-1) = 0] >> >> >> Indeed :) >> now...even if that's correct, do you think there could be side effect in >> other places? > > Not any that won't merely magically start working the way you expect them to, > like say (looking at the senders): > > SmallInteger maxVal +1 numberOfDigitsInBase: 0 > > Cheers, > Henry IntegerTest >> testPowerOfTwo should also be changed though. :P
Cheers, Henry