Mantis - Squeak
Viewing Issue Advanced Details
6873 Kernel minor always 01-25-08 21:44 04-18-10 22:05
nicolas cellier  
andreas  
normal  
closed  
fixed  
none    
none trunk  
0006873: [BUG] isPowerOfTwo incorrect for some LargeNegativeInteger
negative SmallInteger are never powers of two. So far, so good.
neither should LargeNegativeInteger be.

Unfortunately some will answer true to isPowerOfTwo, like:

  (31 to: 111 by: 8) allSatisfy: [:n | (2 raisedTo: n) negated isPowerOfTwo]

Just too bad...
One more case of algorithm correct in restricted area but not in general case...

Cure is easy, override isPowerOfTwo in LargeNegativeInteger to simply ^false
related to 0006874closed nicolas cellier digitLogic:op:len: is not correct 
 isPowerOfTwo-Test-M6873-nice.1.cs [^] (732 bytes) 01-25-08 22:00
 isPowerOfTwo-Patch-M6873-nice.1.cs [^] (588 bytes) 01-25-08 22:00

Notes
(0011711)
nicolas cellier   
01-25-08 22:05   
"fix begin"
Installer mantis bug: 6873 fix:'isPowerOfTwo-Patch-M6873-nice.1.cs'.
"fix test"
Installer mantis bug: 6873 fix:'isPowerOfTwo-Test-M6873-nice.1.cs'.
"fix end"
(0011712)
nicolas cellier   
01-26-08 00:07   
Now i think algorithm was correct.
What is incorrect is #bitAnd: implemented in #digitLogic:op:length:

So my patch is only a workaround against a symptom...
forget the patch and look at 0006874

(0011715)
nicolas cellier   
01-26-08 01:55   
"fix begin"
Installer mantis ensureFix: 6874.
"fix test"
Installer mantis bug: 6873 fix:'isPowerOfTwo-Test-M6873-nice.1.cs'.
"fix end"
(0013317)
nicolas cellier   
09-19-09 21:10   
This has been fixed in trunk with 0006874