nim-stint/stint/private/compiletime_helpers.nim

10 lines
332 B
Nim
Raw Normal View History

2019-10-09 01:51:53 +00:00
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)