--- a/SmallInteger.st Wed Jan 20 02:09:54 2016 +0100
+++ b/SmallInteger.st Wed Jan 20 02:45:31 2016 +0100
@@ -987,40 +987,40 @@
bitAt:anIntegerIndex
"return the value of the index's bit (index starts at 1) as 0 or 1.
Notice: the result of bitAt: on negative receivers is not
- defined in the language standard (since the implementation
- is free to choose any internal representation for integers)"
+ defined in the language standard (since the implementation
+ is free to choose any internal representation for integers)"
%{ /* NOCONTEXT */
#ifdef __SCHTEAM__
return context._RETURN( self.bitAt(anIntegerIndex));
#else
if (__isSmallInteger(anIntegerIndex)) {
- INT idx = __smallIntegerVal(anIntegerIndex);
- if (idx > 0) {
- if (idx > N_INT_BITS) {
- RETURN(__mkSmallInteger(0));
- }
- RETURN((__smallIntegerVal(self) & (1 << (idx-1))) ? __mkSmallInteger(1) : __mkSmallInteger(0));
- }
+ INT idx = __smallIntegerVal(anIntegerIndex);
+ if (idx > 0) {
+ if (idx > N_INT_BITS) {
+ RETURN(__mkSmallInteger(0));
+ }
+ RETURN((__smallIntegerVal(self) & ((INT)1 << (idx-1))) ? __mkSmallInteger(1) : __mkSmallInteger(0));
+ }
}
#endif /* not __SCHTEAM__ */
%}.
^ SubscriptOutOfBoundsError
- raiseRequestWith:anIntegerIndex
- errorString:'index out of bounds'
+ raiseRequestWith:anIntegerIndex
+ errorString:'index out of bounds'
"
- 16r00000001 bitAt:0
- 16r00000001 bitAt:1
- 16r00000001 bitAt:2
- 16r00008000 bitAt:16
- 16r00800000 bitAt:24
- 16r08000000 bitAt:28
- 16r10000000 bitAt:29
- 16r20000000 bitAt:30
- 16r40000000 bitAt:31
- 16r80000000 bitAt:32
+ 16r000000001 bitAt:0 -> error
+ 16r000000001 bitAt:1
+ 16r000000001 bitAt:2
+ 16r000008000 bitAt:16
+ 16r000800000 bitAt:24
+ 16r008000000 bitAt:28
+ 16r010000000 bitAt:29
+ 16r020000000 bitAt:30
+ 16r040000000 bitAt:31
+ 16r080000000 bitAt:32
16r100000000 bitAt:33
"
@@ -1028,9 +1028,9 @@
|mask|
anIntegerIndex <= 0 ifTrue:[
- ^ SubscriptOutOfBoundsSignal
- raiseRequestWith:anIntegerIndex
- errorString:'index out of bounds'
+ ^ SubscriptOutOfBoundsSignal
+ raiseRequestWith:anIntegerIndex
+ errorString:'index out of bounds'
].
(anIntegerIndex > SmallInteger maxBits) ifTrue:[^ 0].
mask := 1 bitShift:(anIntegerIndex - 1).
@@ -1561,21 +1561,21 @@
%{ /* NOCONTEXT */
#ifndef __SCHTEAM__
if (__isSmallInteger(anInteger)) {
- int index = __intVal(anInteger);
-
- if (index > 0) {
+ int index = __intVal(anInteger);
+
+ if (index > 0) {
# if __POINTER_SIZE__ == 8
- if (index <= 62)
+ if (index <= 62)
# else
- if (index <= 30)
+ if (index <= 30)
# endif
- {
- INT mask = __MASKSMALLINT(1 << (index-1));
-
- RETURN ( ((OBJ) ((INT)self & ~(INT)mask)) );
- }
- RETURN (self); /* nothing to do ... */
- }
+ {
+ INT mask = __MASKSMALLINT( ((INT)1 << (index-1)));
+
+ RETURN ( ((OBJ) ((INT)self & ~(INT)mask)) );
+ }
+ RETURN (self); /* nothing to do ... */
+ }
}
#endif /* not __SCHTEAM__ */
%}.
@@ -1596,6 +1596,7 @@
(16rF0000001 clearBit:30) hexPrintString
(16rF0000001 clearBit:31) hexPrintString
(16rF0000001 clearBit:32) hexPrintString
+ (16r1F0000001 clearBit:33) hexPrintString
"
!
@@ -1743,20 +1744,20 @@
%{ /* NOCONTEXT */
#ifndef __SCHTEAM__
if (__isSmallInteger(anInteger)) {
- int index = __intVal(anInteger);
-
- if (index > 0) {
+ int index = __intVal(anInteger);
+
+ if (index > 0) {
# if __POINTER_SIZE__ == 8
- if (index <= 62)
+ if (index <= 62)
# else
- if (index <= 30)
+ if (index <= 30)
# endif
- {
- INT mask = __MASKSMALLINT(1 << (index-1));
-
- RETURN ( ((OBJ) ((INT)self ^ (INT)mask)) );
- }
- }
+ {
+ INT mask = __MASKSMALLINT((INT)1 << (index-1));
+
+ RETURN ( ((OBJ) ((INT)self ^ (INT)mask)) );
+ }
+ }
}
#endif /* not __SCHTEAM__ */
%}.
@@ -1992,20 +1993,20 @@
%{ /* NOCONTEXT */
#ifndef __SCHTEAM__
if (__isSmallInteger(anInteger)) {
- int index = __intVal(anInteger);
-
- if (index > 0) {
+ int index = __intVal(anInteger);
+
+ if (index > 0) {
# if __POINTER_SIZE__ == 8
- if (index <= 62)
+ if (index <= 62)
# else
- if (index <= 30)
+ if (index <= 30)
# endif
- {
- INT mask = __MASKSMALLINT(1 << (index-1));
-
- RETURN ( ((OBJ) ((INT)self | (INT)mask)) );
- }
- }
+ {
+ INT mask = __MASKSMALLINT((INT)1 << (index-1));
+
+ RETURN ( ((OBJ) ((INT)self | (INT)mask)) );
+ }
+ }
}
#endif /* not __SCHTEAM__ */
%}.