6 ms·
Do you also prefer "standard" lengths of decimal numbers, and if so, what are those? On a related note, I once had the weirdest bug in a C program that I could
by svantana 11y ago
Do you also prefer "standard" lengths of decimal numbers, and if so, what are those?
On a related note, I once had the weirdest bug in a C program that I couldn't figure out. It turns out that I had stylized an array of integers with preceding zeros, like: {025, 057, 112} to make it pretty. Little did I know that those zeros made the numbers octal!
- Cyph0n 11y agoWith binary especially I feel it's easier to read if the number is written out in nibbles. Besides, many of us were introduced to binary through ASCII, so the 8 bit format feels even more natural imo. Oh damn, that must have been tough to find!
- B1FF_PSUVM 11y agoAh, the oblivious tyranny of the victorious 8-bitters. The days of the 6-bit register or the 18 or 36 bit words are gone, dust beneath the heels of the conquering hordes of the 8008 microprocessor heirs.
- Natsu 11y agoYes, I do prefer standard lengths of decimal numbers. With decimal numbers, we break every group of 3 up with a comma. It's much easier to read 1,000,000 than 10000000, after all. If you disagree, I hope you noticed that I wrote two different numbers (1 and 10 million). So I prefer if you break up binary numbers on either 4 or 8 bit boundaries with a space and leading zeroes, as is very common in hex editors. So I'd have written either 01100100 or 0110 0100, either of which would be easier to interpret.
- jacobolus 11y agoUsing an initial 0 to indicate octal is a terrible convention. I’m very glad that Python 3 makes 0123 into a syntax error, and uses the form 0o123 instead for octal literals, to match the style of 0x53 (also adds 0b1010011 for binary).
- Tiksi 11y agoI wonder if there's a reason for keeping the leading 0 there past tradition/convention. 0x as a prefix makes sense to differentiate between 0x12 and 012, but if it's 0x 0b and 0o, imo it'd make more sense to drop it and just leave it as o12, b12, x12, etc.
- MaxGabriel 11y agoo12, b12, and x12 are all valid variable names
- Tiksi 11y agoYeah... not sure how that slipped my mind, seems quite obvious now. Thanks
- deleted 11y ago[deleted]
- chj 11y agoI prefer the Scheme way: #x53, #o123, #b1010011 It feels more natural to my taste. We already use #1, #2, ...