4 ms·
I've been programming for 30 years, across many different languages from assembler and up. I've yet to use octals for any code. What am I missing out on? Why a
by magicalhippo 7y ago
I've been programming for 30 years, across many different languages from assembler and up. I've yet to use octals for any code.
What am I missing out on? Why are they included in modern languages like JS?
- aliceryhl 7y agoI once used octals in php: I had to specify the permissions for some file, and those should be in octal. I assume JS has it because so does everyone else.
- userbinator 7y agoAlmost certainly due to C heritage.
- peterwwillis 7y agoIf you ever want to count in base-8 (or a subset), or have an abbreviated form of binary, or pack decimal in a way that's easier to reason, or divide a number in half (down to 1) without getting fractions, or represent file permissions (a grouping of four octals). Is JS a modern language? It was made 24 years ago as a prototype for a scripting language loosely mimicing Java. Presumably octals would have been still used often on recent machines.
- magicalhippo 7y ago> If you ever want to count in base-8 (or a subset) So far I haven't ever had that need it seems. > have an abbreviated form of binary Yeah ok, but why octal over hex? After all, hex maps better to the underlying storage. > pack decimal in a way that's easier to reason How'd that work? I know about BCD but I don't see how octal improves the situation, being base-8. > divide a number in half (down to 1) without getting fractions Huh? > represent file permissions (a grouping of four octals) Ok, I get that for C and such, but how often do you do that in JS? > Is JS a modern language? Compared to C, where octal support is understandable, I'd say yes.