952 " |
952 " |
953 ! |
953 ! |
954 |
954 |
955 lowBit |
955 lowBit |
956 "return the bitIndex of the lowest bit set. The returned bitIndex |
956 "return the bitIndex of the lowest bit set. The returned bitIndex |
957 starts at 1 for the least significant bit. Returns -1 if no bit is set. |
957 starts at 1 for the least significant bit. |
|
958 Returns 0 if no bit is set. |
958 For negative numbers, the low bit of my absolute value is returned. |
959 For negative numbers, the low bit of my absolute value is returned. |
959 Redefined here for more performance of the gcd: algorithm, which |
960 Redefined here for more performance of the gcd: algorithm, which |
960 is used when big fractions are reduced." |
961 is used when big fractions are reduced (should we write a primitive for this ?)." |
961 |
962 |
962 |sz "{ Class: SmallInteger }" |
963 |sz "{ Class: SmallInteger }" |
963 byte| |
964 byte| |
964 |
965 |
965 sz := digitByteArray size. |
966 sz := digitByteArray size. |
966 1 to:sz do:[:digitIndex | |
967 1 to:sz do:[:digitIndex | |
967 (byte := digitByteArray at:digitIndex) ~~ 0 ifTrue:[ |
968 (byte := digitByteArray at:digitIndex) ~~ 0 ifTrue:[ |
968 ^ (digitIndex-1)*8 + byte lowBit |
969 ^ (digitIndex-1)*8 + byte lowBit |
969 ] |
970 ] |
970 ]. |
971 ]. |
971 ^ -1 |
972 ^ 0 "/ should not happen |
972 |
973 |
973 " |
974 " |
974 (1 bitShift:30) lowBit |
975 (1 bitShift:30) lowBit |
975 (1 bitShift:30) highBit |
976 (1 bitShift:30) highBit |
976 (1 bitShift:31) lowBit |
977 (1 bitShift:31) lowBit |
982 (1 bitShift:64) lowBit |
983 (1 bitShift:64) lowBit |
983 (1 bitShift:64) highBit |
984 (1 bitShift:64) highBit |
984 (1 bitShift:1000) lowBit |
985 (1 bitShift:1000) lowBit |
985 (1 bitShift:1000) highBit |
986 (1 bitShift:1000) highBit |
986 ((1 bitShift:64)-1) lowBit |
987 ((1 bitShift:64)-1) lowBit |
987 ((1 bitShift:64)-1) highBit |
988 ((1 bitShift:64)-1) highBit |
|
989 |
|
990 |num| |
|
991 |
|
992 num := (1 bitShift:1000). |
|
993 Time millisecondsToRun:[ |
|
994 100000 timesRepeat:[ |
|
995 num lowBit |
|
996 ] |
|
997 ] |
988 " |
998 " |
989 |
999 |
990 "Modified: 14.8.1997 / 11:55:34 / cg" |
1000 "Modified: 14.8.1997 / 11:55:34 / cg" |
991 ! ! |
1001 ! ! |
992 |
1002 |