Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strutils: toBin(64) uses '/' for the 63rd bit if it's set #11369

dylanagreen opened this issue May 31, 2019 · 1 comment


None yet
3 participants
Copy link

commented May 31, 2019


import strutils
var num: int64 = -1
echo num.toBin(64)

Current Output


Expected Output


Additional Information

Output of nim --version:

Nim Compiler Version 0.19.9 [MacOSX: amd64]
Compiled at 2019-05-29
Copyright (c) 2006-2019 by Andreas Rumpf

active boot switches: -d:release

Code produces the expected output on 0.19.6.

@Araq Araq added the Showstopper label Jun 1, 2019


This comment has been minimized.

Copy link

commented Jun 1, 2019

Same issue with toOct:

echo toOct(-1, 64)
# 000000000000000000000000000000000000000000/777777777777777777777

The output is different for toHex (sign extension instead of filling with zeros):

echo toHex(-1, 64)

Also all integers are passed as BiggestInt so echo toBin(-1'i8, 64) gives the same output as echo toBin(-1'i64, 64).

@Araq Araq added the Regression label Jun 2, 2019

Araq added a commit that referenced this issue Jun 2, 2019

@Araq Araq closed this in 5eb47f8 Jun 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.