summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJuan Carlos <juancarlospaco@gmail.com>2022-11-03 05:44:11 -0300
committerGitHub <noreply@github.com>2022-11-03 09:44:11 +0100
commit46eac22172dff7a59def6f5f79ab7bf4e2eefd96 (patch)
tree097bbb3f2f51b2512edc4c8d36e6aeabafcf9c55
parent0b1d1b7886396d943a54843c63e4dc0604db0cdb (diff)
downloadNim-46eac22172dff7a59def6f5f79ab7bf4e2eefd96.tar.gz
Improve dollar int (#20737)
Improve dollar
-rw-r--r--compiler/int128.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/int128.nim b/compiler/int128.nim
index 4791954a2..e357706b9 100644
--- a/compiler/int128.nim
+++ b/compiler/int128.nim
@@ -429,7 +429,7 @@ proc `mod`*(a, b: Int128): Int128 =
 proc addInt128*(result: var string; value: Int128) =
   let initialSize = result.len
   if value == Zero:
-    result.add "0"
+    result.add '0'
   elif value == low(Int128):
     result.add "-170141183460469231731687303715884105728"
   else:
@@ -450,6 +450,8 @@ proc addInt128*(result: var string; value: Int128) =
       j -= 1
 
 proc `$`*(a: Int128): string =
+  # "-170141183460469231731687303715884105728".len == 41
+  result = newStringOfCap(41)
   result.addInt128(a)
 
 proc parseDecimalInt128*(arg: string, pos: int = 0): Int128 =