add fromDecimal to io

This commit is contained in:
jangko 2023-06-20 21:39:37 +07:00
parent e99bc7ff89
commit 3ef8d0027a
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 5 additions and 2 deletions

View File

@ -292,11 +292,14 @@ func parse*[bits: static[int]](input: string,
if isNeg:
result.negate
func fromHex*(T: typedesc[StUint|StInt], s: string): T =
func fromHex*(T: typedesc[StUint|StInt], s: string): T {.inline.} =
## Convert an hex string to the corresponding unsigned integer
parse(s, type result, radix = 16)
func hexToUint*[bits: static[int]](hexString: string): StUint[bits] =
func fromDecimal*(T: typedesc[StUint|StInt], s: string): T {.inline.} =
parse(s, type result, radix = 10)
func hexToUint*[bits: static[int]](hexString: string): StUint[bits] {.inline.} =
## Convert an hex string to the corresponding unsigned integer
parse(hexString, type result, radix = 16)