10 lines
332 B
Nim
10 lines
332 B
Nim
import ./datatypes, ./uint_bitwise_ops
|
|
|
|
func getByte*(x: SomeInteger, pos: int): byte {.compileTime.} =
|
|
type DT = type x
|
|
byte((x shr (pos * 8)) and 0xFF.DT)
|
|
|
|
func getByte*(x: UintImpl | IntImpl, pos: int): byte {.compileTime.} =
|
|
type DT = type x.leastSignificantWord
|
|
byte((x shr (pos * 8)).leastSignificantWord and 0xFF.DT)
|