From dc4a30c6b16f306d8baab086d71bc2a5aae91682 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 1 Jun 2016 17:59:21 +0200 Subject: [PATCH] adds strutils.toHex variant that knows about the used integer size --- lib/pure/strutils.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 22641bca22..f59313450d 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -542,6 +542,10 @@ proc toHex*(x: BiggestInt, len: Positive): string {.noSideEffect, # handle negative overflow if n == 0 and x < 0: n = -1 +proc toHex*[T](x: T): string = + ## Shortcut for ``toHex(x, T.sizeOf * 2)`` + toHex(x, T.sizeOf * 2) + proc intToStr*(x: int, minchars: Positive = 1): string {.noSideEffect, rtl, extern: "nsuIntToStr".} = ## Converts `x` to its decimal representation.