r/AskComputerScience • u/coffee-mugz • May 26 '21
Why does a kilobyte = 1024?
Hoping for some help and want to say thanks in advance. I’m having trouble getting this and I’ve read several sites that all say it’s because computers operate in binary and 210 = 1024, but this doesn’t make sense to me.
Here’s what I think are true statements:
1) A bit is the fundamental unit of a computer and it can either be a 0 or a 1.
2) A byte is 8 bits.
Why then can’t 1 kilobyte be 1,000 bytes or 8,000 bits?
Am I thinking about 210 wrong? Doesn’t 210 just represents 10 bits? Each bit has two options and you have 10 of them so 210 combinations. I suspect that’s where I’ve got my misconception but I can’t straighten it out
29
u/teraflop May 26 '21
210 is just a number. We could define whatever units we wanted; the real question is, why are units of data storage often measured with powers of two?
Imagine you're building a random-access memory chip that stores one byte of data at a time. In order to tell the chip which byte to access, you need to provide an address, which is a binary number. If there are N bits available to specify the address, then the maximum size of your memory chip is 2N bytes. And since each bit requires hardware (address decoders, multiplexers, etc.), you usually want to make full use of the available address space.
By using powers of two as our units, we tend to end up with nice round numbers. It's convenient to define "1 KiB = 210 bytes", so that we can refer to a memory chip with 216 bytes as having 64 KiB of memory, as opposed to 65.536 KB.
The really annoying thing is that the units aren't consistent across different situations. There are binary kilobytes ("kibibytes" or KiB), which are 1024 bytes, and there are decimal kilobytes (KB) which are 1000 bytes. RAM modules and CPU caches tend to use the former, in order to get round numbers; things like magnetic hard drives use the latter, because they don't have anything specifically constraining them to use powers of two, and using decimal units makes the numbers look bigger. And unfortunately, the word "kilobyte" is often thrown around without being precise about which unit it refers to.
2
u/deong May 26 '21
Inside the machine, we technically don't really care that much about kilobytes, megabytes, etc. Memory is just a big array of addressable storage locations, and "addressable" here just means that we can number each storage location and refer to them by number.
Because computers are binary, those addresses, like everything else, are represented as binary numbers -- combinations of 0s and 1s. In principle, I could have any number of those storage locations, but if that number is a power of two, it makes everything easier, because I don't have to worry about what address 111 means in a computer that only has 6 memory locations. If I wanted 1000 bytes of memory, I'd need 10 bits to store an address. But 10 bits gives 1024 possible addresses. Those extra 24 addresses are bogus in that world, and you need to build circuits to deal with the consequences of that. Why bother going through that effort when you could just add 24 more bytes of memory?
18
u/khedoros May 26 '21
Point of nomenclature: A kilobyte is 1000 bytes. A kibibyte is 1024 bytes. Granted, people do often use "kilo" to refer to both.
Yes. 10 bits, 1024 possible combinations.
3
u/romanhaller May 26 '21 edited May 26 '21
Basically when coining these terms, peoples thought process was: "The kilo prefix would mean 1000, in reality it's 1024, but close enough". Equally for the other prefixes.
That's a horrible approach of course. See here for the details:
http://stopabusingsiprefixes.org/stopabusing.html
3
u/JoshYx May 26 '21
I tried making coherent sentences to explain this but it's late and my brain is not working so I'll put it in bullet points:
Anyway, I hope this helps.
2
u/jhaluska May 26 '21
Mainly because 210 bytes can't be stored in 1000 bytes. You need 1024. This is done mainly because humans can say 1 Kilobyte faster than 1024 bytes verbally. This holds true up till Gigabytes where things start getting weird.
2
u/Bottled_Void May 26 '21
It's because back in the day, you would NEVER need the SI unit version. Which is easier? I have 500KB of storage or I have 524.288KB. Having KB mean 1024 bytes just made all the numbers nicer.
1
u/SuRGeoNix May 29 '24 edited May 29 '24
Is just for marketing purposes... you pay for 1TB and you buy 931GB
1
u/Few-Pin8378 Jan 12 '25
Ne pas oublier le 0 qui correspond à un etat 20=1 21=2 22=4 23=8 24=16 25=32 26=64 27=128 28=256 29=512 210=1024
1
u/SteeleDynamics May 26 '21
shakes fist
Damn you nomenclature!!
5
u/[deleted] May 26 '21
[removed] — view removed comment