‹ BackHN Continuity

Thread

C's Flexible Integer Sizes Were Not a Design Mistake

113 points · 166 comments · ibobev

  1. RobotToaster · · focus · HN ↗
    > A 'plain' int object has the natural size suggested by the architecture of the execution environment.

    Shouldn't they be 64 bits on most modern systems then?

    1. entrope · · focus · HN ↗
      > Shouldn't they be 64 bits on most modern systems then?

      Arguably so, but then one would lose the ability to natively name 16-bit integer types because "short" would be 32 bits.

      An earlier comment addresses x86-64. AArch64 (pedantically, the A64 instruction set used for AArch64&#x27;s 64-bit execution mode) is similar, in that addresses are 64 bits wide but ALU instructions typically encode a width bit, called &quot;sf&quot;, that selects either 32- or 64-bit data registers and arithmetic. See, for example, <a href="https:&#x2F;&#x2F;arm.jonpalmisc.com&#x2F;latest_aarch64&#x2F;add_addsub_ext" rel="nofollow">https:&#x2F;&#x2F;arm.jonpalmisc.com&#x2F;latest_aarch64&#x2F;add_addsub_ext .

      1. imtringued · · focus · HN ↗
        char is at least 8 bits, short is at least 16 bits, long is at least 32 bits, long long is at least 64 bits.

        Not sure how what you said makes sense.

        1. entrope · · focus · HN ↗

          [dead]

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.