mirror of
https://github.com/status-im/nim-stint.git
synced 2025-02-16 17:07:23 +00:00
* implement arithmetic right shift * workaround Nim VM 'cast' limitation * fix high(stint) bug * fix compile time bit shift bug * add test for compile time shift and high(stint) * add tests against ttmath
20 lines
547 B
Nim
20 lines
547 B
Nim
import ../stint, ttmath
|
|
export ttmath
|
|
|
|
template asSt*(val: UInt): auto =
|
|
type TargetType = StUint[val.NumBits]
|
|
cast[ptr TargetType](unsafeAddr val)[]
|
|
|
|
template asSt*(val: Int): auto =
|
|
type TargetType = StInt[val.NumBits]
|
|
cast[ptr TargetType](unsafeAddr val)[]
|
|
|
|
template asTT*[N: static[int]](arr: array[N, uint64]): auto =
|
|
type TargetType = UInt[N * 64]
|
|
cast[ptr TargetType](unsafeAddr arr[0])[]
|
|
|
|
template asTT*[N: static[int]](arr: array[N, int64]): auto =
|
|
type TargetType = Int[N * 64]
|
|
cast[ptr TargetType](unsafeAddr arr[0])[]
|
|
|