Enable range checking for unsigned integers (#11313)
* Enable range checking for unsigned integers * Make the tests green
This commit is contained in:
parent
70fb3a93e9
commit
3a06022071
5 changed files with 24 additions and 7 deletions
|
|
@ -13,7 +13,7 @@ proc toByteArrayBE*[T: SomeInteger](num: T): ByteArrayBE[sizeof(T)]=
|
|||
## Notice the result type
|
||||
const N = T.sizeof
|
||||
for i in 0 ..< N:
|
||||
result[i] = byte(num shr ((N-1-i) * 8))
|
||||
result[i] = byte((num shr ((N-1-i) * 8)) and high(int8))
|
||||
|
||||
let a = 12345.toByteArrayBE
|
||||
echo a[^2 .. ^1] # to make it work on both 32-bit and 64-bit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue