hit counter code

Tuesday, August 19, 2008

1's & 0's: Base-2 and bytes- How characters are stored

You may have noticed a pattern now that looks strangely familiar in the world of electronics. Specifically if you have ever purchased a memory card for your camera or RAM (Random Access Memory) for your computer you have noticed that it comes in these strange base-2 numbers like 128K, 256MB, 512, or even 1024K of RAM.

Ah, but what does all of that mean? Interestingly enough when you count by base-2 or 2^7 you will notice you get these “funky” numbers like 128 or that 2^10 is actually 1024. Hold that thought for just a moment.

Given the background you know have you know that our letter “A” represented by the decimal “65” or by 01000001 in binary zero's and ones' stores this one character. Well one character is typically a byte or eight bits. A bit is simply a zero or a one and a byte (8 bits) can then represent any number from 0 to 255 as we have seen above.

So, each character of this long post is represented in the computer as a byte—a number from 0 to 255 that corresponds to a character in the ASCII (say “Ask Key two”) table. If I put the word “word” in the computer it is represented by four bytes. You'd say the document (if strictly ASCII text with no formatting) would then take up 4 bytes of space.


No comments: