summary refs log tree commit diff stats
path: root/compiler/renderer.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-05-13 17:25:57 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-05-13 17:25:57 +0200
commit69658ad396424e2b184e669e3835835a53a34775 (patch)
tree078c333e8755f4167d43b8d8dd04e40a44a5a469 /compiler/renderer.nim
parentf84293ac8f50009d2d615639424ef6385620a6c9 (diff)
downloadNim-69658ad396424e2b184e669e3835835a53a34775.tar.gz
fixes #11131
Diffstat (limited to 'compiler/renderer.nim')
-rw-r--r--compiler/renderer.nim7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index 56f57b25a..115fd0201 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -323,9 +323,10 @@ proc litAux(g: TSrcGen; n: PNode, x: BiggestInt, size: int): string =
         result &= e.sym.name.s
         return
 
-  if nfBase2 in n.flags: result = "0b" & toBin(x, size * 8)
-  elif nfBase8 in n.flags: result = "0o" & toOct(x, size * 3)
-  elif nfBase16 in n.flags: result = "0x" & toHex(x, size * 2)
+  let y = x and ((1 shl (size*8)) - 1)
+  if nfBase2 in n.flags: result = "0b" & toBin(y, size * 8)
+  elif nfBase8 in n.flags: result = "0o" & toOct(y, size * 3)
+  elif nfBase16 in n.flags: result = "0x" & toHex(y, size * 2)
   else: result = $x
 
 proc ulitAux(g: TSrcGen; n: PNode, x: BiggestInt, size: int): string =