right shift is now by default sign preserving (#11322)
* right shift is now by default sign preserving * fix hashString and semfold * enable arithmetic shift right globally for CI * fix typo * remove xxx * use oldShiftRight as flag * apply feedback * add changelog entry
This commit is contained in:
parent
897e7c90ac
commit
88b5dd3362
18 changed files with 211 additions and 187 deletions
|
|
@ -75,20 +75,20 @@ proc bitSetContains(x, y: TBitSet): bool =
|
|||
const populationCount: array[low(int8)..high(int8), int8] = block:
|
||||
var arr: array[low(int8)..high(int8), int8]
|
||||
|
||||
proc countSetBits(x: int8): int8 =
|
||||
proc countSetBits(x: uint8): uint8 =
|
||||
return
|
||||
( x and 0b00000001'i8) +
|
||||
((x and 0b00000010'i8) shr 1) +
|
||||
((x and 0b00000100'i8) shr 2) +
|
||||
((x and 0b00001000'i8) shr 3) +
|
||||
((x and 0b00010000'i8) shr 4) +
|
||||
((x and 0b00100000'i8) shr 5) +
|
||||
((x and 0b01000000'i8) shr 6) +
|
||||
((x and 0b10000000'i8) shr 7)
|
||||
( x and 0b00000001'u8) +
|
||||
((x and 0b00000010'u8) shr 1) +
|
||||
((x and 0b00000100'u8) shr 2) +
|
||||
((x and 0b00001000'u8) shr 3) +
|
||||
((x and 0b00010000'u8) shr 4) +
|
||||
((x and 0b00100000'u8) shr 5) +
|
||||
((x and 0b01000000'u8) shr 6) +
|
||||
((x and 0b10000000'u8) shr 7)
|
||||
|
||||
|
||||
for it in low(int8)..high(int8):
|
||||
arr[it] = countSetBits(it)
|
||||
arr[it] = cast[int8](countSetBits(cast[uint8](it)))
|
||||
|
||||
arr
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue