0

1024 = 2 to the power 10. Computers use binary system where the base is 2 (0 and 1). Humans use decimal system where the base is 10. So if I have 1 byte which contains 8 bit in modern computers I can represent up to 256 different states, possibilities, values or such. 10 bits can represent 1024 states. Well..so what? What does it have to do with memory? I think memory size it's about number of bits/bytes not about number of states that bits and bytes can represent. I'm confused. What the technical benefit from thinking 1K(i)B = 1024 and not 1000 bytes?

I think I need more technical explanation maybe something related how CPU works or how data actually stores at hard drive. Not just: hey computer use binary form so we use 2^10 and not 10^2.

Timur Fayzrakhmanov
  • 17,967
  • 20
  • 64
  • 95
  • 1
    Did you bother to google this question: [why is a kb 1024 bytes?](https://www.google.com/search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q=why%20is%20a%20kb%201024%20bytes%3F&oq=why%20is%20a%20kb%201024%20bytes%3F&aqs=chrome..69i57j0l2.8678j0j7) There are *many* answers... – David Zemens Jun 12 '15 at 14:17
  • Yep, I have already read them all – Timur Fayzrakhmanov Jun 12 '15 at 14:17
  • http://stackoverflow.com/questions/19819763/really-1-kb-kilobyte-equals-1024-bytes – David Zemens Jun 12 '15 at 14:18
  • Thanks, but it is not what I look for. – Timur Fayzrakhmanov Jun 12 '15 at 14:20
  • 1
    "When computer scientists wanted prefixes to describe large numbers of bytes, they decided to "borrow" the prefixes used in the metric system....since 1024 = 2^10 is very close to 1000 = 10^3, those scientists decided to call 1024 bytes a "kilobyte" and to describe it as being "about 1000 bytes." [linky](http://mathforum.org/library/drmath/view/54359.html) – David Zemens Jun 12 '15 at 14:20
  • @HighPerformanceMark, yes you are right - it is my mistake. – Timur Fayzrakhmanov Jun 12 '15 at 14:24

3 Answers3

2

What does it have to do with memory?

It has to do with memory addressing, which is done using binary numbers as well.

On a very high level, a typical memory chip works like this: it has pins of three types - address pins, data pins, and control pins. When CPU needs to read or write memory, it sets up a combination of zeros and ones on the address pins of a memory chip, sends a read or write signal to the control pins, waits a little, and then reads or writes data using the data pins.

The combination of zeros and ones placed on the address pins is called memory address. It is a binary number in the range from zero to 2n, where n is the number of address pins.

This is how the powers of two get into measuring the capacity of memory. Conveniently, 1024 was very near 1000, so "K" was borrowed to mean 1024 when talking about memory size.

Note that measuring data sizes using binary multiples is not universal. For example, capacities of hard drives are often quoted using decimal, not binary multiples, because hard drives do not inherently use binary addressing (and the number of decimal gigabytes is higher, which helps marketing the product).

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
1

What does it have to do with memory?

Obviously all these sizes are powers of 2. The reason it's 1024 and 1024^2 is because it's an exact description of what you get.

It's easy to address memory when you use the building blocks of a computer. These building blocks are address pins, and having more corresponds to powers of 2.

That said, we can also just call it '1000'. It's just less exact in most cases, and therefore makes less sense in the general case. There are exceptions though: most harddisks actually use powers of 10 for the capacity. You notice that when you put it in your computer, and the '24' suddenly starts to make a difference. :-)

atlaste
  • 30,418
  • 3
  • 57
  • 87
1

Memory management is historically done in powers of two because powers of two can be performed using bit shifts. If the system had 1024 pages, the hardware can identify the page simply extracting (or shifting) bits.

In disk drives, 1K is 1000 bytes. This was done for marketing purposes. Disk drive manufacturers could advertise slightly larger capacities. This is true even though drives work with blocks whose sizes are powers of 2.

user3344003
  • 20,574
  • 3
  • 26
  • 62
  • Hm..that's good. Originally my question was raised when I discovered I can easily identify number of bytes, for example, of file with 32 MiB using bit shift (32 << 20). Could you explain "If the system had 1024 pages, the hardware can identify the page simply extracting (or shifting) bits." in more detail? All I know about page it is the smallest unit of data of OS's virtual memory using for memory management. – Timur Fayzrakhmanov Jun 12 '15 at 16:20
  • 1
    A page is the basic unit of memory management. Difference systems use different page sizes. The olde VAX used 512 bytes. Now 4K is the most common page size. Assuming have as in your example a 1K page (10 bits) that means the lowest 10 bits of the an address specify the offset into a page and the remaining bits (22 or 54) specify the page. The hardware uses these bits to translate logical addresses to physical addresses. – user3344003 Jun 13 '15 at 04:23
  • My english isn't quite good.. I can't catch your idea. You say: "as in your example a 1K page (10 bits [maybe 1000bits?]) that means the lowest 10 bits of the an address [what does it mean 'the lowest bits of an address'?]". How you work out 22 and 54? I'm sorry, but it really hard to understand you( – Timur Fayzrakhmanov Jun 13 '15 at 18:39
  • 1
    If you have 1K pages, that takes 10 bits to represent a byte within the page. If you have a 32-bit address, that leave 22 bit to specify the page. If you have a 64 bit address, that leaves 54 bits to specify the page. An address then a combination of a page selection and a byte within the page selection. – user3344003 Jun 14 '15 at 04:39