Files
Nim/tests/stdlib/tbitops_utils.nim
Timothee Cour e78ef57c93 typetraits: add toSigned, toUnsigned (#18445)
* typetraits: add toSigned, toUnsigned

* improve and add tests

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: flywind <xzsflywind@gmail.com>
2022-04-07 17:38:01 -04:00

15 lines
278 B
Nim

import std/private/bitops_utils
template chk(a, b) =
let a2 = castToUnsigned(a)
doAssert a2 == b
doAssert type(a2) is type(b)
doAssert type(b) is type(a2)
chk 1'i8, 1'u8
chk -1'i8, 255'u8
chk 1'u8, 1'u8
chk 1'u, 1'u
chk -1, cast[uint](-1)
chk -1'i64, cast[uint64](-1)