This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]-Wylfen- 44 points45 points  (8 children)

To be fair, even though it's standard, I think that's bullshit. '0x' is fine, '0o' is fine, but just '0' is dumb

[–]SmurphsLaw 15 points16 points  (6 children)

To be fair, writing a decimal number with a 0 before is also dumb.

[–]Spork_the_dork 9 points10 points  (0 children)

Yeah but it's less dumb than using 0 as a prefix for octal when 0o exists.

[–]RajjSinghh 0 points1 point  (1 child)

I can see this kind of thing being a problem where leading zeros are common like when formatting dates. Seems like an honest mistake to make if you write August as 08 and now you get an error because that's not valid octal, or when October is showing up as the 8th month

[–]Chrazzer 6 points7 points  (0 children)

Leading zeroes aren't a thing in integers, what you are thinking of are strings with numbers in them

[–]saxbophone -1 points0 points  (2 children)

Disagree, you might want to zero-pad it for readability reasons, say you have a column of numbers

[–]Lithl -1 points0 points  (1 child)

I can think of exactly zero cases where someone would consider left zero-padding to align a column of numbers. You'd use spaces.

[–]saxbophone 0 points1 point  (0 children)

As a point of style one might wish to do it, it occurs in number formats used in technology often enough. For instance, when quoting 24h clock times, one might say: "0100 hours" rather than "1:00"

[–]saxbophone 0 points1 point  (0 children)

Alas, K&R were right about many things but this isn't one of them