equal
deleted
inserted
replaced
800 -9 quo:4 |
800 -9 quo:4 |
801 " |
801 " |
802 ! ! |
802 ! ! |
803 |
803 |
804 |
804 |
|
805 |
805 !SmallInteger methodsFor:'bit operators'! |
806 !SmallInteger methodsFor:'bit operators'! |
806 |
807 |
807 bitAnd:anInteger |
808 bitAnd:anInteger |
808 "return the bitwise-and of the receiver and the argument, anInteger" |
809 "return the bitwise-and of the receiver and the argument, anInteger" |
809 |
810 |
1131 ! |
1132 ! |
1132 |
1133 |
1133 clearBit:anInteger |
1134 clearBit:anInteger |
1134 "return a new integer where the specified bit is off. |
1135 "return a new integer where the specified bit is off. |
1135 Bits are counted from 1 starting with the least significant. |
1136 Bits are counted from 1 starting with the least significant. |
1136 The methods name may be missleading: the receiver is not changed, |
1137 The methods name may be misleading: the receiver is not changed, |
1137 but a new number is returned. Should be named #withBitCleared:" |
1138 but a new number is returned. Should be named #withBitCleared:" |
1138 |
1139 |
1139 %{ /* NOCONTEXT */ |
1140 %{ /* NOCONTEXT */ |
1140 |
1141 |
1141 if (__isSmallInteger(anInteger)) { |
1142 if (__isSmallInteger(anInteger)) { |
1142 int index = __intVal(anInteger); |
1143 int index = __intVal(anInteger); |
1143 |
1144 |
1144 if (index > 0) { |
1145 if (index > 0) { |
1145 #if __POINTER_SIZE__ == 8 |
1146 #if __POINTER_SIZE__ == 8 |
1146 if (index <= 62) |
1147 if (index <= 62) |
1147 #else |
1148 #else |
1148 if (index <= 30) |
1149 if (index <= 30) |
1149 #endif |
1150 #endif |
1150 { |
1151 { |
1151 INT mask = __MASKSMALLINT(1 << (index-1)); |
1152 INT mask = __MASKSMALLINT(1 << (index-1)); |
1152 |
1153 |
1153 RETURN ( ((OBJ) ((INT)self & ~(INT)mask)) ); |
1154 RETURN ( ((OBJ) ((INT)self & ~(INT)mask)) ); |
1154 } |
1155 } |
1155 RETURN (self); /* nothing to do ... */ |
1156 RETURN (self); /* nothing to do ... */ |
1156 } |
1157 } |
1157 } |
1158 } |
1158 %}. |
1159 %}. |
1159 ^ super clearBit:anInteger |
1160 ^ super clearBit:anInteger |
1160 |
1161 |
1161 " |
1162 " |
1280 ! |
1281 ! |
1281 |
1282 |
1282 invertBit:anInteger |
1283 invertBit:anInteger |
1283 "return a new number where the specified bit is inverted. |
1284 "return a new number where the specified bit is inverted. |
1284 Bits are counted from 1 starting with the least significant. |
1285 Bits are counted from 1 starting with the least significant. |
1285 The methods name may be missleading: the receiver is not changed, |
1286 The methods name may be misleading: the receiver is not changed, |
1286 but a new number is returned. Should be named #withBitInverted:" |
1287 but a new number is returned. Should be named #withBitInverted:" |
1287 |
1288 |
1288 %{ /* NOCONTEXT */ |
1289 %{ /* NOCONTEXT */ |
1289 |
1290 |
1290 if (__isSmallInteger(anInteger)) { |
1291 if (__isSmallInteger(anInteger)) { |
1291 int index = __intVal(anInteger); |
1292 int index = __intVal(anInteger); |
1292 |
1293 |
1293 if (index > 0) { |
1294 if (index > 0) { |
1294 #if __POINTER_SIZE__ == 8 |
1295 #if __POINTER_SIZE__ == 8 |
1295 if (index <= 62) |
1296 if (index <= 62) |
1296 #else |
1297 #else |
1297 if (index <= 30) |
1298 if (index <= 30) |
1298 #endif |
1299 #endif |
1299 { |
1300 { |
1300 INT mask = __MASKSMALLINT(1 << (index-1)); |
1301 INT mask = __MASKSMALLINT(1 << (index-1)); |
1301 |
1302 |
1302 RETURN ( ((OBJ) ((INT)self ^ (INT)mask)) ); |
1303 RETURN ( ((OBJ) ((INT)self ^ (INT)mask)) ); |
1303 } |
1304 } |
1304 } |
1305 } |
1305 } |
1306 } |
1306 %}. |
1307 %}. |
1307 ^ super invertBit:anInteger |
1308 ^ super invertBit:anInteger |
1308 |
1309 |
1309 " |
1310 " |
1316 (16r0 invertBit:31) hexPrintString |
1317 (16r0 invertBit:31) hexPrintString |
1317 (16r0 invertBit:32) hexPrintString |
1318 (16r0 invertBit:32) hexPrintString |
1318 (16r0 invertBit:33) hexPrintString |
1319 (16r0 invertBit:33) hexPrintString |
1319 (16r0 invertBit:100) hexPrintString |
1320 (16r0 invertBit:100) hexPrintString |
1320 " |
1321 " |
1321 |
|
1322 |
|
1323 ! |
1322 ! |
1324 |
1323 |
1325 lowBit |
1324 lowBit |
1326 "return the bitIndex of the lowest bit set. The returned bitIndex |
1325 "return the bitIndex of the lowest bit set. The returned bitIndex |
1327 starts at 1 for the least significant bit. |
1326 starts at 1 for the least significant bit. |
1501 ! |
1500 ! |
1502 |
1501 |
1503 setBit:anInteger |
1502 setBit:anInteger |
1504 "return a new integer where the specified bit is on. |
1503 "return a new integer where the specified bit is on. |
1505 Bits are counted from 1 starting with the least significant. |
1504 Bits are counted from 1 starting with the least significant. |
1506 The methods name may be missleading: the receiver is not changed, |
1505 The methods name may be misleading: the receiver is not changed, |
1507 but a new number is returned. Should be named #withBitSet:" |
1506 but a new number is returned. Should be named #withBitSet:" |
1508 |
1507 |
1509 %{ /* NOCONTEXT */ |
1508 %{ /* NOCONTEXT */ |
1510 |
1509 |
1511 if (__isSmallInteger(anInteger)) { |
1510 if (__isSmallInteger(anInteger)) { |
1512 int index = __intVal(anInteger); |
1511 int index = __intVal(anInteger); |
1513 |
1512 |
1514 if (index > 0) { |
1513 if (index > 0) { |
1515 #if __POINTER_SIZE__ == 8 |
1514 #if __POINTER_SIZE__ == 8 |
1516 if (index <= 62) |
1515 if (index <= 62) |
1517 #else |
1516 #else |
1518 if (index <= 30) |
1517 if (index <= 30) |
1519 #endif |
1518 #endif |
1520 { |
1519 { |
1521 INT mask = __MASKSMALLINT(1 << (index-1)); |
1520 INT mask = __MASKSMALLINT(1 << (index-1)); |
1522 |
1521 |
1523 RETURN ( ((OBJ) ((INT)self | (INT)mask)) ); |
1522 RETURN ( ((OBJ) ((INT)self | (INT)mask)) ); |
1524 } |
1523 } |
1525 } |
1524 } |
1526 } |
1525 } |
1527 %}. |
1526 %}. |
1528 ^ super setBit:anInteger |
1527 ^ super setBit:anInteger |
1529 |
1528 |
1530 " |
1529 " |
4186 ! ! |
4185 ! ! |
4187 |
4186 |
4188 !SmallInteger class methodsFor:'documentation'! |
4187 !SmallInteger class methodsFor:'documentation'! |
4189 |
4188 |
4190 version |
4189 version |
4191 ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.203 2013-04-15 13:07:21 cg Exp $' |
4190 ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.204 2013-04-25 07:02:27 stefan Exp $' |
4192 ! |
4191 ! |
4193 |
4192 |
4194 version_CVS |
4193 version_CVS |
4195 ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.203 2013-04-15 13:07:21 cg Exp $' |
4194 ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.204 2013-04-25 07:02:27 stefan Exp $' |
4196 ! ! |
4195 ! ! |
4197 |
4196 |