--- a/SmallInteger.st Mon Apr 18 07:17:25 2016 +0100
+++ b/SmallInteger.st Wed Apr 20 07:02:04 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
@@ -967,6 +965,7 @@
! !
+
!SmallInteger methodsFor:'bit operators'!
bitAnd:anInteger
@@ -1547,38 +1546,38 @@
!
highBit
- "return the bitIndex of the highest bit set. The returned bitIndex
- starts at 1 for the least significant bit.
+ "return the bitIndex of the highest bit set.
+ The returned bitIndex starts at 1 for the least significant bit.
Returns 0 if no bit is set."
%{ /* NOCONTEXT */
#ifdef __SCHTEAM__
{
- long bits = self.longValue();
- int bitNr = 0;
-
- if (bits != 0) {
- if ((bits & 0xFFFFFFFF00000000L) != 0) {
- bitNr += 32; bits >>= 32;
- }
- if ((bits & 0xFFFF0000L) != 0) {
- bitNr += 16; bits >>= 16;
- }
- if ((bits & 0xFF00) != 0) {
- bitNr += 8; bits >>= 8;
- }
- if ((bits & 0xF0) != 0) {
- bitNr += 4; bits >>= 4;
- }
- if ((bits & 0xC) != 0) {
- bitNr += 2; bits >>= 2;
- }
- if ((bits & 0x2) != 0) {
- bitNr += 1; bits >>= 1;
- }
- bitNr += 1;
- }
- return context._RETURN( STInteger._new(bitNr) );
+ long bits = self.longValue();
+ int bitNr = 0;
+
+ if (bits != 0) {
+ if ((bits & 0xFFFFFFFF00000000L) != 0) {
+ bitNr += 32; bits >>= 32;
+ }
+ if ((bits & 0xFFFF0000L) != 0) {
+ bitNr += 16; bits >>= 16;
+ }
+ if ((bits & 0xFF00) != 0) {
+ bitNr += 8; bits >>= 8;
+ }
+ if ((bits & 0xF0) != 0) {
+ bitNr += 4; bits >>= 4;
+ }
+ if ((bits & 0xC) != 0) {
+ bitNr += 2; bits >>= 2;
+ }
+ if ((bits & 0x2) != 0) {
+ bitNr += 1; bits >>= 1;
+ }
+ bitNr += 1;
+ }
+ return context._RETURN( STInteger._new(bitNr) );
}
/* NOTREACHED */
#else
@@ -1587,7 +1586,7 @@
bits = __intVal(self);
if (bits == 0) {
- RETURN ( __mkSmallInteger(0) );
+ RETURN ( __mkSmallInteger(0) );
}
# ifdef __BSR
@@ -1603,23 +1602,23 @@
# if __POINTER_SIZE__ == 8
if (bits & 0xFFFFFFFF00000000L) {
- index += 32; bits >>= 32;
+ index += 32; bits >>= 32;
}
# endif
if (bits & 0xFFFF0000L) {
- index += 16; bits >>= 16;
+ index += 16; bits >>= 16;
}
if (bits & 0xFF00) {
- index += 8; bits >>= 8;
+ index += 8; bits >>= 8;
}
if (bits & 0xF0) {
- index += 4; bits >>= 4;
+ index += 4; bits >>= 4;
}
if (bits & 0xC) {
- index += 2; bits >>= 2;
+ index += 2; bits >>= 2;
}
if (bits & 0x2) {
- index += 1; bits >>= 1;
+ index += 1; bits >>= 1;
}
# endif /* no BSR instruction */
@@ -1637,38 +1636,38 @@
2r100000000000 highBit
((0 to:64) collect:[:s | 1 bitShift:s])
- collect:[:n | n highBit]
+ collect:[:n | n highBit]
(((0 to:64) collect:[:s | 1 bitShift:s])
- collect:[:n | n highBit]) = (1 to:65)
+ collect:[:n | n highBit]) = (1 to:65)
"
"
Time millisecondsToRun:[
- 1000000 timesRepeat:[
- 2r1 highBit
- ]
+ 1000000 timesRepeat:[
+ 2r1 highBit
+ ]
]
"
"
Time millisecondsToRun:[
- 1000000 timesRepeat:[
- 2r1111 highBit
- ]
+ 1000000 timesRepeat:[
+ 2r1111 highBit
+ ]
]
"
"
Time millisecondsToRun:[
- 1000000 timesRepeat:[
- 2r11111111111111 highBit
- ]
+ 1000000 timesRepeat:[
+ 2r11111111111111 highBit
+ ]
]
"
"
Time millisecondsToRun:[
- 1000000 timesRepeat:[
- 2r11111111111111111111111111 highBit
- ]
+ 1000000 timesRepeat:[
+ 2r11111111111111111111111111 highBit
+ ]
]
"