I often find myself explaining the same things in real life and online, so I recently started writing technical blog posts.

This one is about why it was a mistake to call 1024 bytes a kilobyte. It’s about a 20min read so thank you very much in advance if you find the time to read it.

Feedback is very much welcome. Thank you.

  • wischi@programming.devOP
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    19
    ·
    11 months ago

    Binary prefixes (the ones with 1024 conversations) are used to simplify numbers that are exact powers of two - for example RAM and similar types of memory. Hard drive sizes are never exact powers of two. Disk storing bits don’t have anything to do with the size of the disk.

    • silly goose meekah@lemmy.world
      link
      fedilink
      English
      arrow-up
      9
      arrow-down
      2
      ·
      11 months ago

      sure, but one of the intrinsic properties of binary data is that it is in binary sized chunks. you won’t find a hard drive that stores 1000 bits of data per chunk.

      • abhibeckert@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        arrow-down
        2
        ·
        edit-2
        11 months ago

        The “chunk” is often 32,768 bits these days and it never matches the actual size of the drive.

        A 120 GB drive might actually be closer to 180 GB when it’s brand new (if it’s a good drive - cheap ones might be more like 130 GB)… and will get smaller as the drive wears out with normal use. I once had a HDD go from 500 GB down to about 50 GB before I stopped using it - it was a work computer and only used for email so 50 GB was when it actually started running out of space.

        HDD / SSD sellers are often accused of being stingy - but the reality is they’re selling a bigger drive than what you’re told you’re getting.

      • wischi@programming.devOP
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        8
        ·
        11 months ago

        Look up the exact number of bytes and then explain to me what the benefits are of using 1024 conversations instead of 1000 for a hard drive?

      • wischi@programming.devOP
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        11 months ago

        Not even SSDs are. Do you have an SSD? You should lookup the exact drive size in bytes, it’s very likely not an exact power of two.

          • wischi@programming.devOP
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            11 months ago

            The underlying chips certainly are exact powers of two but the drive size you get as a consumer is practically never an exact power of two, that’s why it doesn’t really make sense to divide by 1024.

            The size you provided would be 500107862016 / 1024 / 1024 / 1024 = 465.76174163818359375 GiB

            Divided by 1000³ it would be 500.107862016 GB, so both numbers are not “pretty” and would’ve to be rounded. That’s why there is no benefit in using 1024 for storage devices, even SSDs.

            The situation is a bit different with RAM. 16 “gig” modules are exactly 17179869184 bytes. https://www.wolframalpha.com/input?i=prime+factors+of+17179869184

            So you could say 17.179869184 GB or 16 GiB. Note that those 16 GiB are not rounded and the exact number of bytes for that RAM module. So for memory like caches, RAM, etc. it definitely makes sense to use binary prefixes with 1024 conversion but for storage devices it wouldn’t make a difference because you’d have to round anyway.

            • gens@programming.dev
              link
              fedilink
              English
              arrow-up
              1
              ·
              11 months ago

              It’s the size in bytes as the os sees it (and in SMART). And i do know how to use a calculator, thank you.

              There is also no benefit to using 1000. Except to hdd makers.

              • wischi@programming.devOP
                link
                fedilink
                English
                arrow-up
                1
                ·
                edit-2
                11 months ago

                There is a benefit in using 1000 because it’s consistent with all the other 1000 conversions from kg to gramm, km to meter, etc. And you can do it in your head because we use a base 10 number system.

                36826639 bytes are 36.826639 MB. But how many MiB? I don’t know, I couldn’t tell you without a calculator.

                • gens@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  edit-2
                  11 months ago

                  You don’t have to know. It does not matter because your 8GB stick can’t fit 16 512MB files anyway. Funny enough it might fit 500MB files if it is FAT32.

                  Being consistent with base10 systems does not matter in real world usage. Literally nobody cared before the asshats changed it.

                  Edit: i also understand si, down to its history. I don’t live in an inch country. Computing is different then physical measurements. In computing 1024 is more “correct”.