From 3ef8d0027a04127180f3c5a3f2b26d1f99ded6ef Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 20 Jun 2023 21:39:37 +0700 Subject: [PATCH] add fromDecimal to io --- stint/io.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stint/io.nim b/stint/io.nim index 2458102..25024e4 100644 --- a/stint/io.nim +++ b/stint/io.nim @@ -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)