I Love Binary Numbers!

Most people haven’t thought very hard about numbers. I’ve always loved numbers.

In the 5th grade, Mrs. Lamberson explained numbering systems to us. She informed us that the numbers we’re used to seeing are in the “base 10” numbering system.
“Base” means the base of an exponential function. Each position in the number tells you what the exponent in that function is. The rightmost digit in a number is in the “0 exponent” position, so the number “32” means there’s a 2 in the 0 position and a 3 in the 1 position.
0 position? Ok, hang in here.
The 0 position is where you put the digit that counts the number multiplied by the base to the power of zero. Everything to the power of zero is 1, so the 0 position holds the 1’s.
In a base-10 system, the 1 position is where you put the digit that counts the number multiplied by the base to the power of one. Everything to the power of 1 is the base itself. So, in this case, this is the number of 10’s.
So, 32 = ( 3 x 101 ) + ( 2 x 100) = ( 3 x 10 ) + ( 2 x 1 ) = 30 + 2.
And this continues. The 2 position holds the number of 100’s because 100 is 102 or 10 x 10.
And the 3 position holds 1000’s or 10 x 10 x 10.
In the computer world we use other numbering systems out of convenience.
The digital computer does all it’s thinking in terms of on and off. A value of on or off is stored in a bit of memory. We represent that value as 0 (off) or 1 (on).
Humans seem to need numbers larger than 1, so the computer has to be able to represent and do math operations on larger numbers. In a computer, larger numbers are stored using a base-2 numbering system called binary.
Binary numbers are represented like decimal numbers. The least significant digit (or bit) is always on the right side. Because the numbering system is base-2, every position can only hold a 0 or 1.
Think about it, in the decimal, base-10 system, every position can only hold 0-9, or one less than the base of the system. This is, of course, by design. We want to represent a value with a single character when we write.
So, in binary, you might have the number 11. This is a 1 in the 0 position and a 1 in the 1 position.
The 0 position in base-2, as with all numbering systems, holds the count of 1’s. And the 1 position holds the count of 2’s.
Quick check of this: The 0 position holds the number of 20‘s. 20 is 1. And the 1 position holds the number of 21‘s. 21 is 2.
And the system goes on. The 2 position holds 22‘s or 2×2 or 4’s. The 3 position holds 23‘s or 2x2x2 or 8’s.
From there it goes 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8072, 16384, 32768, 65536… and on.
So the binary, base-2 number 1010 has 0 in the 0 position, 1 in the 1 position, 0 in the 2 position, and 1 in the 3 position. We can ignore the zeros and just add up 2 + 8. So 1010 in binary is 10 in decimal. Decimal 11 in binary would be 1011. If you add one more, 12 would be 1100. 13 would be 1101. 14 would be 1110 (see, it’s 2 + 4 + 8). 15 would be 1111. At 16, something magical happens… a new position is used. 16 is 10000.
You might recognize some of those numbers in the powers of two table. I remember when home computers had 16k or 64k of memory. I remember when it was a big deal to get a video card with 128mb of memory. You might notice that flash drives come in 2, 4, 8, 16, 32gb sizes.
Computers usually have these increments of memory because that memory has to be addressed by the microprocessor. It’s most efficient if the CPU can address the memory with a single number, the offset of the memory it needs from the beginning of memory. The number 0 would address the first piece of memory, 1 would address the second, and so on.
The 64kb computers, like the Commodore 64 and the Apple IIe, had 8-bit CPUs. This means that those CPUs really only dealt with information in 8-bit (called a “byte”) chunks.
But those processors were designed to look at memory as a number of 8-bit segments into which there was an 8-bit offset. So, there were 256 segments each storing 256 bytes. 256×256 = 65536. This is called 64 kilobytes of memory, or 64 x 1024 bytes.
Whew.
This really is interesting. If you’re still reading, I’m amazed. I think I have a job because so few people find this exciting.
So, on the 8-bit machines, they really couldn’t add another byte of memory without having much more powerful processing because it would have required more than two bytes to address it.
The 8086 series of Intel processors were 16-bit processors with a 20-bit external addressing bus. They could address more memory through a segment/offset scheme based on 20-bits. The segment would be 4 bits, each addressing a 64kb segment. The offset was a 16-bit number, 0-65535 addressing the memory within that segment.
4 bits stores numbers from 0-15. If all 4 bits are on, 1111, then it’s 1 + 2 + 4 + 8 or 15.
So, you could have 16 64kb segments, total of 1,048,576 which is 1 megabyte. A megabyte is not really one million bytes. It’s 1024 kilobytes. A kilobyte is 1024 bytes. So, a megabyte is 1024 x 1024.
Later Intel processors were 32-bits with a 32-bit address bus. The CPU could address any byte of memory within a 4,294,967,296 byte space (4 gb of memory).
The 64-bit processors could theoretically address 18,446,744,073,709,551,616 bytes which is 16 exabytes.
8 bits = 1 byte
1024 bytes = 1 kilobyte
1024 kilobytes = 1,048,576 bytes = 1 megabyte
1024 megabytes = 1,073,741,824 bytes = 1 gigabyte
1024 gigabytes = 1,099,511,627,776 = 1 terabyte
1024 terabytes = 1,125,899,906,842,624 = 1 petabyte
1024 petabytes = 1,152,921,504,606,846,976 = 1 exabyte
Of course, you can’t really afford to buy 16 exabytes of RAM for your computer.
If a 16gb stick of RAM for your computer is $500 (cheapest I found) then you would need 1024 x 1024 x 1024 of those, or 1,073,741,824 of those, or $536,870,912,000 worth.
Maybe you could get a volume discount.
And that’s cheap RAM. Higher quality manufacturing is going to cost you twice that. So, you’re going to need like $1 trillion to buy RAM.
You better ask the Chinese for a loan, that’s what the US Government does.
On a 64-bit Intel processor, Windows supports virtual address space of 16 terabytes. It can page memory out to disk up to 256 terabytes. (The virtual address space is the address space available to any one program. If there isn’t enough physical memory on the computer to keep the whole thing in memory, then chunks are saved to disk and read back in when needed.)
This is enough.
Don’t you love numbers?

Comments

2 responses to “I Love Binary Numbers!”

  1. Well then, I must go find your blog… right now.

  2. I think I love binary numbers more than you do (I have a whole blog about them!).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.