3 ms·
Jesus this is some dumb shit. In python, the string returned by bin(decimal) drops the leading zeros >>> bin(3) '0b11' >>> bin(513) '0b1
by isoprophlex 7y ago
Jesus this is some dumb shit.
In python, the string returned by
bin(decimal)
drops the leading zeros
>>> bin(3)
'0b11'
>>> bin(513)
'0b1000000001'
>>> bin(1024)
'0b10000000000'
I don't want to turn this into a personal attack or an overly snarky comment but it's really something to try and implement a bit counting algo by hand and then fail to observe the way bin() behaves
- dang 7y ago> I don't want to turn this into a personal attack or an overly snarky comment That's a fine intention, but then you shouldn't lead with "Jesus this is some dumb shit" or end with "it's really something to try and [...] fail." Doing it that way breaks the site guidelines. Would you mind reviewing them? https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html Note that the leading guideline in the "comments" section is Be kind.
- isoprophlex 7y agoBelated, but, yeah. You're right. I blew my top a bit there...