equal
deleted
inserted
replaced
488 ^ self bitShift:(aNumber negated) |
488 ^ self bitShift:(aNumber negated) |
489 |
489 |
490 " |
490 " |
491 1 >> -5 |
491 1 >> -5 |
492 64 >> 5 |
492 64 >> 5 |
493 " |
|
494 ! |
|
495 |
|
496 isBitSet:index |
|
497 "return true if the index' bit is set; false otherwise. |
|
498 Bits are counted from 1 starting with the least significant." |
|
499 |
|
500 ^ (self bitAt:index) ~~ 0 |
|
501 |
|
502 " |
|
503 5 isBitSet:3 => true |
|
504 2r0101 isBitSet:2 => false |
|
505 2r0101 isBitSet:1 => true |
|
506 2r0101 isBitSet:0 index error |
|
507 " |
|
508 ! |
|
509 |
|
510 setBit:index |
|
511 "return a new number where the specified bit is on. |
|
512 Bits are counted from 1 starting with the least significant." |
|
513 |
|
514 ^ self bitOr:(1 bitShift:index-1) |
|
515 |
|
516 " |
|
517 0 setBit:3 => 4 (2r100) |
|
518 0 setBit:48 => 140737488355328 (2r1000.....000) |
|
519 ((0 setBit:99) setBit:100) printStringRadix:2 |
|
520 " |
493 " |
521 ! ! |
494 ! ! |
522 |
495 |
523 !Integer methodsFor:'bcd conversion'! |
496 !Integer methodsFor:'bcd conversion'! |
524 |
497 |
1004 "Modified: 5.11.1996 / 14:06:40 / cg" |
977 "Modified: 5.11.1996 / 14:06:40 / cg" |
1005 ! |
978 ! |
1006 |
979 |
1007 clearBit:index |
980 clearBit:index |
1008 "return a new number where the specified bit is off. |
981 "return a new number where the specified bit is off. |
1009 Bits are counted from 1 starting with the least significant." |
982 Bits are counted from 1 starting with the least significant. |
|
983 The methods name may be missleading: the receiver is not changed, |
|
984 but a new number is returned. Should be named #withBitCleared:" |
1010 |
985 |
1011 |n "{ Class: SmallInteger }" |
986 |n "{ Class: SmallInteger }" |
1012 byteIndex "{ Class: SmallInteger }" |
987 byteIndex "{ Class: SmallInteger }" |
1013 bitIndex "{ Class: SmallInteger }" |
988 bitIndex "{ Class: SmallInteger }" |
1014 result byte| |
989 result byte| |
1074 (1 bitShift:1000) negated highBit |
1049 (1 bitShift:1000) negated highBit |
1075 ((1 bitShift:64)-1) highBit |
1050 ((1 bitShift:64)-1) highBit |
1076 " |
1051 " |
1077 |
1052 |
1078 "Modified: / 3.5.1999 / 09:20:57 / stefan" |
1053 "Modified: / 3.5.1999 / 09:20:57 / stefan" |
|
1054 ! |
|
1055 |
|
1056 isBitSet:index |
|
1057 "return true if the index' bit is set; false otherwise. |
|
1058 Bits are counted from 1 starting with the least significant." |
|
1059 |
|
1060 ^ (self bitAt:index) ~~ 0 |
|
1061 |
|
1062 " |
|
1063 5 isBitSet:3 => true |
|
1064 2r0101 isBitSet:2 => false |
|
1065 2r0101 isBitSet:1 => true |
|
1066 2r0101 isBitSet:0 index error |
|
1067 " |
1079 ! |
1068 ! |
1080 |
1069 |
1081 lowBit |
1070 lowBit |
1082 "return the bitIndex of the lowest bit set. The returned bitIndex |
1071 "return the bitIndex of the lowest bit set. The returned bitIndex |
1083 starts at 1 for the least significant bit. Returns -1 if no bit is set." |
1072 starts at 1 for the least significant bit. Returns -1 if no bit is set." |
1147 16r112233445566778899 odd |
1136 16r112233445566778899 odd |
1148 16r112233445566778800 odd |
1137 16r112233445566778800 odd |
1149 " |
1138 " |
1150 |
1139 |
1151 "Created: / 6.6.1999 / 15:00:55 / cg" |
1140 "Created: / 6.6.1999 / 15:00:55 / cg" |
|
1141 ! |
|
1142 |
|
1143 setBit:index |
|
1144 "return a new number where the specified bit is on. |
|
1145 Bits are counted from 1 starting with the least significant. |
|
1146 The methods name may be missleading: the receiver is not changed, |
|
1147 but a new number is returned. Should be named #withBitCleared:" |
|
1148 |
|
1149 ^ self bitOr:(1 bitShift:index-1) |
|
1150 |
|
1151 " |
|
1152 0 setBit:3 => 4 (2r100) |
|
1153 0 setBit:48 => 140737488355328 (2r1000.....000) |
|
1154 ((0 setBit:99) setBit:100) printStringRadix:2 |
|
1155 " |
1152 ! ! |
1156 ! ! |
1153 |
1157 |
1154 !Integer methodsFor:'byte access'! |
1158 !Integer methodsFor:'byte access'! |
1155 |
1159 |
1156 digitByteLength |
1160 digitByteLength |
2564 ! ! |
2568 ! ! |
2565 |
2569 |
2566 !Integer class methodsFor:'documentation'! |
2570 !Integer class methodsFor:'documentation'! |
2567 |
2571 |
2568 version |
2572 version |
2569 ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.127 2000-01-17 11:13:38 cg Exp $' |
2573 ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.128 2000-01-25 10:12:12 cg Exp $' |
2570 ! ! |
2574 ! ! |
2571 Integer initialize! |
2575 Integer initialize! |