Skip to content
DevMeme
5032 of 7435
Pre-ANSI C's Surprising Octal Number System
TechHistory Post #5508, on Sep 23, 2023 in TG

Pre-ANSI C's Surprising Octal Number System

Description

This image is a screenshot of a technical document, likely a programming manual, with a white background and black text. The headings read '2.3 Constants' and '2.3.1 Integer constants'. The main text describes integer constants, stating they are octal if they begin with 0. The most prominent part is a sentence with red underlines beneath each word: 'The digits 8 and 9 have octal value 10 and 11 respectively.' In the bottom right, there is a watermark that says 'More fun at https://t.me/dev_meme'. This is a deep technical joke for experienced programmers, especially those familiar with the history of the C language. The humor comes from the obscurity and counter-intuitive nature of this language rule from pre-standardized, or 'Pre-ANSI', C. In modern computing, the octal number system (base-8) exclusively uses the digits 0 through 7. The idea that 8 and 9 could be considered part of an octal representation is absurd by today's standards. This historical artifact from the Bell Labs C manual highlights how language specifications can evolve and how what is considered fundamental today was once different

Comments

57
Anonymous ★ Top Pick Modern compilers give you errors for invalid octal digits. The original C compiler just shrugged and implemented integer promotion with extra steps. It's not a bug, it's a historical feature
  1. Anonymous ★ Top Pick

    Modern compilers give you errors for invalid octal digits. The original C compiler just shrugged and implemented integer promotion with extra steps. It's not a bug, it's a historical feature

  2. Anonymous

    Pre-ANSI C let 8 and 9 into octal - proof that feature creep can hit even numeral systems, and why the legacy billing job still thinks 089 is “undefined revenue.”

  3. Anonymous

    After 20 years in the industry, I've learned that C's octal literals with leading zeros have caused more production incidents than Y2K - at least Y2K had a marketing budget and consultants warning us about it

  4. Anonymous

    Ah yes, the classic C octal trap - where padding your numbers with a leading zero for 'alignment' suddenly transforms 08 into a compiler error, because apparently Dennis Ritchie thought developers in the 1970s desperately needed a shorthand for base-8 literals. Nothing says 'intuitive language design' quite like silently reinterpreting 0755 as 493 decimal while making 0888 a syntax error. It's the gift that keeps on giving, especially when junior devs wonder why their 'lucky number' 007 doesn't equal seven, and senior architects still debate whether this feature was genius foresight for Unix file permissions or just technical debt we've been carrying since bell-bottoms were fashionable

  5. Anonymous

    Legacy reminder: a leading zero turns your constant into octal - 010 is 8, 08 is a build failure, and 09 is a company-wide retrospective

  6. Anonymous

    Classic C ergonomics: one stray leading 0 turns 09 into a compile error while the doc promotes 8 and 9 to octal - my lexer just filed a bug against the author

  7. Anonymous

    Octal literals now go to 11 - like Spinal Tap volumes, but for the C standard's off-by-one in digit values

  8. @VanuxaKR 2y

    You posted it up there

  9. @VanuxaKR 2y

    https://t.me/dev_meme/5498 Like here

  10. @mihanizzm 2y

    And what's wrong with that?

    1. @beton_kruglosu_totchno 2y

      imagine writing binary number 01001019

      1. @mihanizzm 2y

        That's wrong

        1. @beton_kruglosu_totchno 2y

          And what's wrong with that? :)

          1. @mihanizzm 2y

            9 in binary

            1. @beton_kruglosu_totchno 2y

              bingo

              1. @average_meni_na_drugu_enjoyer 2y

                valid octal digit, not binary digit

                1. @average_meni_na_drugu_enjoyer 2y

                  i see what i missed

      2. @average_meni_na_drugu_enjoyer 2y

        here you have binary

        1. @beton_kruglosu_totchno 2y

          does word "imagine" mean anything to you?

          1. @average_meni_na_drugu_enjoyer 2y

            not really

        2. @zaspirin 2y

          here, have a "valid" octal number: 0789

          1. @average_meni_na_drugu_enjoyer 2y

            that's not valid

            1. @beton_kruglosu_totchno 2y

              you just claimed that the channel admin is lying

              1. @average_meni_na_drugu_enjoyer 2y

                nope

          2. @mihanizzm 2y

            That's wrong

          3. @average_meni_na_drugu_enjoyer 2y

            did i somewhere said that is valid?

            1. @beton_kruglosu_totchno 2y

              yes the fucking post you are commenting under

              1. @mihanizzm 2y

                Post have nothing similar with the documentation that literally tells that thing: 8 = 010 9 = 011

                1. @beton_kruglosu_totchno 2y

                  do you have any idea what digit is?

                  1. @mihanizzm 2y

                    Digits are the single numbers used to represent values in math. 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 are used in different combinations and repetitions to represent all the values in math. Any of the ten numbers from 0 to 9 can be represented by a symbol known as a digit.

                2. @colllapse 2y

                  I think OP made up things outta his ass and claimed that the octals in pre ansi c had decimal digits as valid octal digits, so 08 and 09 woulda resolve to something. But I think op's reading skills is lacking and he took examples as actual values

  11. @mihanizzm 2y

    And what's wrong with the pic?

    1. @beton_kruglosu_totchno 2y

      it's literally doing the same thing you just said is wrong

      1. @mihanizzm 2y

        How?

      2. @average_meni_na_drugu_enjoyer 2y

        man, you are wrong

  12. @mihanizzm 2y

    8 in decimal is 10 in octal

  13. @mihanizzm 2y

    What's wrong?

  14. @average_meni_na_drugu_enjoyer 2y

    octal digit

  15. @mihanizzm 2y

    8 = 010 9 = 011

  16. @mihanizzm 2y

    Where's the problem?

  17. @beton_kruglosu_totchno 2y

    oh i'm dying lmao

  18. @zaspirin 2y

    YEAH, NO SHIT?

  19. @average_meni_na_drugu_enjoyer 2y

    it was valid in C literal because, as i understand, C was transforming them

  20. @callofvoid0 2y

    guys all of this is about pre-ansi C converting any number interpreted as octal to the decimal equivalent by itself

  21. @mihanizzm 2y

    So 8 and 9 are valid decimal digits that have 10 and 11 octal values respectively

  22. @kuklochai 2y

    dev meme admin is trying to tear us apart, we have to stay strong

    1. @callofvoid0 2y

      Strength with Unity Unity with Faith

  23. @anatoli26 2y

    In octal only valid digits are 0-7, so decimal 8 in octal is 10 and decimal 9 in octal is 11. That’s what the manual is saying. Same as to say 2 in decimal is 10 in binary and 3 in decimal is 11 in binary. So nothing wrong is there

    1. dev_meme 2y

      Yesss, let’s explain to best engineers in the field what octal notation is 🎉 This is what standards for languages are made for, right?

      1. @RiedleroD 2y

        well, again, this is pre-ansi C, so that's no standard, that's at best internal documentation, and at worst someone's attempt at explaining some company's internal compiler

      2. @anatoli26 2y

        Maybe you believe you are some sort of The Field Greatest Mind Wizard and because of this you see something that others don't see, but all this post basically is:

  24. @ZgGPuo8dZef58K6hxxGVj3Z2 2y

    But why not do it like every other base does? 36282 is decimal, 0x352416 is hexadecimal, 0b10100101010 is binary. Why not use 0o15272517 to be octal

    1. @ZgGPuo8dZef58K6hxxGVj3Z2 2y

      Or am I missing something?

    2. @colllapse 2y

      you can omit o in octal and just start it with 0. works till this day

  25. @zaspirin 2y

    Here is another post that proves that 8 and 9 were valid octal digits, with an additional source as a proof. https://twitter.com/shafikyaghmour/status/991913614977060866

  26. @pod1425 2y

    Can someone explain to me where the fuck is octal system used nowadays? Or its not actually? I learn C++ for 3 years, only mention of it is that there is IO manipulator for it

  27. @anatoli26 2y

    some doc says 2+2=4!

Use J and K for navigation