Binary Data
It’s no secret that majority of flash programmers are not graduates of a computer science, but rather hobbyists who saw opportunity in a world with a demand for RIA. Keith Peters has a nice post on is intro to flash here
Well I won’t bore you with my beginnings into flash but, because we are not compu-sci majors, we missed out on a few basic principals which will be needed in the future of flash and this post is the beginning of a few of those aspects.
I have spent much time researching these areas and recommend that you look into them as well because they will continue to be in each flash package continuing on.
I will continue to explore bit shifting and hexadecimal and how they relate to one another in a later post which will address the ways in which Byte Array will come in handy. But for now, Binary Data:
Binary as we all know is the language of the computer.
Everyday we sit in front of our computers, the programs we use utilize the combination of 1’s and 0’s and turn those combination into a different language in which we can understand. Such languages I’m speaking of are Unicode, hexadecimal, Decimal and ASCII. These are all languages I will explain in individual blogs how they relate to binary and the AS3 Byte Array.
Each previously stated language has its own base number in which bytes are arranged to define how to use the combination of bytes to represent some form of data.
Binary is a base 2 also stated as Binary has a radix of 2. The 1’s and 0’s i spoke of earlier. Every use of a 1 or 0 is exactly 1 binary digit information known as a bit. 4 bits make up what is known as a nibble, and 2 nibbles make up 1 byte. OK so we learned a lot of gibberish so far.
So what does base 2 really mean? Well lets begin with our own decimal system to explain how base to effects binary.
In our decimal system, we count as accurately to the tens place. as can be seen in this number 4. 4 is a value 0-9 in the 1’s place of our decimal system. If i were to say 24, 4 is still in the 1’s place and 2 is now in the 10’s place. so 4 is really the same Number as (10^0)*4. and the 2 in the 24 is no different than 2*(10^1).
And to put it all together is to say that 24 = 2*(10^1) + (10^0)*4.
OK so really base 10 just means that since we count from 1-9 per column, every time our number moves into the next column , that is the same as notating 10^(exponent++)
Keeping with that mindset, base 2 is the same thing only with 2 in place of 10. 2^0, 2^1, 2^2. And when we do this we find that we don’t get tens hundreds thousands quite so early on.. but rather 1, 2, 4, 8, 16, 32, 64, 128, 256, etc, but just as our number system increases to the left, so does binary so 1,2,4,8 should really be written as thus. 8 4 2 1.
These 4 bits is what is known as a nibble.
That is the binary number system.