Representation of a Kilo/Mega/Tera Byte

前端 未结 3 1472
离开以前
离开以前 2021-01-13 09:22

I was getting a little confused with the representation of different units of bytes.

It is accepted throughout that 1 byte = 8 bits.

However, in a lot of so

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 10:05

    It is accepted throughout that 1 byte = 8 bits

    However, in a lot of sources I have seen that

    1 kiloByte = 2^ 10 bytes = 1024 bytes

    AND

    1 kiloByte = 1000 bytes

    To make sure we're all clear, your question is "Is a kilobyte equal to 1024 bytes or 1000 bytes?".

    Doesn't this contradict as in both cases it is stated that 1 byte is 8 bits...?

    This is irrelevant to the question.

    So, let's begin. In SI (metric), the multiplier of 1000 is called kilo, abbreviated k. k always means 1000, never anything else.

    When binary computers entered the world, we noticed that 2 to the power of 10 is 1024, which is conveniently close to 1000. Computer engineers decided to abuse this coincidence and say that kilo means 1024. By extension, they say that mega means 10242 (instead of the proper definition of 10002), and so on with giga, tera, etc.

    While the difference between 1000 and 1024 is small for many purposes, there are times when exact answers are required, and this is where the abusive terminology hurts everyone. Only after decades after kilo=1024 got established did anyone really try to fix the problem. The IEC proposed new prefixes for the binary multipliers: 1024 = kibi, 10242 = mebi, 10243 = gibi, etc.

    In summary, the notion that kilo=1024 is an abusive deviation from the consistent SI definition of kilo=1000. While kilo=1024 is popular in the computer industry, it is nevertheless wrong and should be replaced by kibi=1024. Or numbers need to be recomputed to reflect the true definition of kilo/mega/etc. (For example, "512 MB" of RAM is actually about 536.9 MB.)

    Btw, don't use random capitalization; it's spelled kilobyte, not kiloByte.

    References and links:

    • http://physics.nist.gov/cuu/Units/binary.html
    • http://en.wikipedia.org/wiki/Kilo-
    • http://en.wikipedia.org/wiki/Kilobyte
    • http://en.wikipedia.org/wiki/Kibibyte
    • http://xkcd.com/394/

提交回复
热议问题