Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
A number preceded by 0 in C is interpreted as octal (like 0x for hex). So 010 is actually 8 which indeed is smaller than 9.
TL;DR It's no bug, it's a feature 😀 -
@Gauthier Oh, sorry. Didn't know that you knew. Was assuming you thought you really found a bug...
-
@kwerdenker it's ok ;) But I do think they should have chosen a better way. Like 8b10, or something like that. I was bitten by this years ago, when I formatted a large byte array with 3 digits for all. It looked better but is didn't work for bytes below 100...
-
@Gauthier As with most things, I assume someone just needed a way to represent a different integer base and had to write his own compiler parser for it. As programmers are known for their lazyne... efficiency, he just said used the simplest way possible. And with most "temporary" things it somehow stuck and is now part of the feature list.
-
@kwerdenker I think it has moreto do with backward compatibility. At the time C was created, octal was much more usual than now.
-
@nerd-san What's so bad? It seems like many here didn't get it right away.
And you know what? Emacs, in termux on my Android phone 😎
Related Rants
Come on, C is fun!
undefined
c