A binary digit ( bit ) is a single digit available
within the base 2 numbering system.
In base 2 there are only 2 digits. 0 and 1. In contrast there are 10 digits in base 10
(decimal) 0,1,.......9. Since all hardware of computers is such that there are only 2
electrical states (on / off), base 2 was chosen as the ideal system for being able to
represent (or show people) what
data looked like in the computer. Also for
was decided to group these bits into clusters of 8 called a byte.
Remember that values ( data ) are what goes into variables. I have already shown you
the different types of variables but let me simplify it even more by saying that even
though there are 8 different types of variables there are only 2 real types of data or
values. How so ? If you look closely you will se that a lot of
the variable types are
variations of each other. ( big, small etc ) In summary then we can say that all data
or values fit into one of two general categories :
used in arithmetic
arithmetic data like addresses
Now I can tell you how data is really stored in memory or on disks.
Alphanumeric data is simple -- there is a unique 16 bit code ( 2 bytes
for every possible character that can
be entered into the computer.
Numeric data is more complicated -- there is a set number of bytes
reserved for each of the various
numeric variables and there is not
a unique 2 byte code for each digit
in the number. All the digits are
treated as a unit and stored in
arithmetic form using base 2.
The following will explain numeric data representation but only for
integers ( whole numbers )
1... accept the fact that decimal and binary are positional numbering
meaning that the true value of the
number is derived by multiplying each digit
by the value of that
digit's position and summing the results
2... everyone knows how to count from 0 to 99 in
decimal, learn to count from 0 to 99
in binary. Remember
that when the maximum digit is reached in a position you
start over at zero in that position BUT
CARRY just like 5th grade mathematics
0000 0001 0010 0011
0100 0101 0110 0111
1000 1001 1010
1011 1100 1101 1110
1111 this was as high as I could go with 4 bits
I think you see the
picture. NOW imagine you had 16 bits to use.........
By the way this is the size of a
variable. Also assume that
you cannot use the leftmost bit
because it is reserved for the sign 1 neg 0
pos. That leaves 15 bits and if they
were all 1's 0111111111111111 you
would have a value of 32767 in
decimal or ( 2 to the 16 power ) minus 1.
the above carefully because it is the basis
for storing numerical values in the computer
variables are 32 bits in size and long integers are 64 bits.
The principle noted above however is
the same for these types.