MATHEMATICS OF COMPUTERS
(can you count to "one" ?)
AND BINARY NUMBERS
Since computers use BINARY ( BI means two,
as in BI- cycle, for a TWO wheeled bike,
or BI-Plane, for a plane with two wings - one
on top of the other, typically the older wooden
planes from the parent, Wright Brothers first
BI-nary numbers only have ( 2 ) TWO numbers.
a ZERO ( 0 ) and a ONE ( 1 ).
Before we start doing the mathematics of BINARY,
it is very important to understand ordinary,
everyday DECIMAL numbers. You might think that
you already know DECIMAL numbers, since you
have been using them for years, but there are a
few CONCEPTS that most people take for granted
since they "use" the numbers every day, without thinking
about some of the things that happen in simple counting!
First, DEC-imal is based on ( 10 ) TEN numbers,
( which you are thinking, I already know that ),
and if I ask you to count all the fingers on both your
hands, you will count, 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10.
Similarly, if I ask you "What are the TEN numbers in the
decimal system?" you probably make the mistake
of saying that the numbers are:
1, 2, 3, 4, 5, 6, 7, 8, 9, and 10
It is very common to start counting at ONE (1 ).
ALSO, " 10 " ( TEN ) is not a number, it is two numbers,
a ONE ( 1 ) and a ZERO ( 0 ).
For thousands of years, entire Civilizations, such as
the Roman Empire, were missing the most important
number -- ZERO (0 ). This crippled their mathematics,
and made Accounting, and Science and Engineering
very difficult, and sometimes, impossible.
Although we take for granted that everyone in the
world uses DECIMAL ( 10 ) based mathematics, this is
NOT the general rule if you look for hundreds and
thousands of years into the past.
In a survey of 1920, Eskimos never counted more than
the number 5 in everyday use. In their lifetime, it was almost silly
to think of having 25 igloos, or 25 kayaks, or 25 harpoons.
If you asked an Eskimo, " how many igloos do you have",
they would probably reply " ONE ". To see
counting numbers in 5,000 languages, CLICK HERE.
In Australia, a number of Aboriginal languages had
two counting numbers, for example, the Watchandies
tribe, used cooteon for one and utaura for two.
Three would be cooteon/utaura ( one/two ) while
four would be ataura/utaura. (two/two)
Any number more, was booltha, or "MANY"
Again, the idea idea of having 25 spears, or
25 boomarangs, was impractical and not needed.
Other Civilizations used FIVE (5) numbers in counting,
or (3 ) THREE numbers, or ( 6 ) numbers, so, Historically,
10 ( TEN ) DECIMAL numbers is only a recently used
System. Some languages, such as Yumbri, had NO numbers
at all, just the words, neremoy (little) and nakobe (much).
The area of the Yumbri has ancient ruins such as these.
The discovery of ( 0 ) ZERO in " OUR " computer
world is recent as well, although ancient, and what were
termed " Primitive " Civilizations, have been using it for
thousands of years, even if they used a system of 5, 20, or 60.
MAYAN symbols, used either pictures of complex
characters , or just the heads of characters, or
a simplified character set of 3 symbols: a DOT = 1
a LINE = 5, and a CLAMSHELL = 0. Groups of
numbers are each 20 times bigger, 1's, 20's and 400's.
Only 4 MAYAN " CODICES" or books survived, and the
Dresden book showed the orbits of the planets. In the
picture below, from page 9, the Goddess of CORN is
shown on the left. By using the extremely accurate calenders,
the Mayans knew when to plant seeds. To see the actual books
CLICK HERE. http://kidbots.com/MATH/codex.html
A good LINK on the web to view different Mayan
NUMBERS is at CLICK HERE.
OK, back to DECIMAL, ( 10 ) based number systems...
The TEN ( 10 ) numbers in DECIMAL, are:
0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
NOTE ! ! ! There is NO number 10 ( TEN ) in the DECIMAL,
or " 10 " ( TEN ) based counting system !!!
The biggest counting number you can use in a TEN ( 10 )
based counting system is TEN minus ONE equals " 9 ".
Lets look at ordinary DECIMAL counting in detail and point
out some obvious, but interesting things that happen.
If you start counting, you get:
9 -At which point, you run out of numbers.
Now, you ADD 9 PLUS 1, in the ONES column,
NOTE WHAT HAPPENS ! !
YUP... 9 plus 1 = ZERO !!!
You probably add NINE plus ONE and get
the answer ZERO every day, without thinking
about it, but it is a VERY important point !
There is one more step to do ...
CARRY A ONE (1) into the next column,
and start counting all over again at ZERO ( 0 ).
AGAIN, at this point, you add a ONE (1) to the NINE (9)
= 0 AGAIN, 9 + 1 = 0 ( ZERO ), in the ones column,
Now you CARRY a ONE into the next column , and
start counting from ZERO again...
2 3 etc.
When you count up to 99, again you run out of numbers,
and you take the last (9 ) nine, CARRY a one over to
the next column, and reset the NINE ( 9) to Zero
1+ ( add (1) ONE to the last 9 )
( RESET the last 9 to a ZERO ( 0 ) )
9 0 ( Again, note that 99 + 1 = 90 ! ! )
1 + ( and once more, we CARRY a 1 )
Then the FIRST ( 9), adds to one, RESETS to ZERO (0 ),
and CARRIES a One to the next COLUMN.
1 0 0
OK, lets try this again in the QUADernary system....
In a QUAD ( 4 ) system, there are 4 numbers,
0, 1, 2, and 3
if you start counting, you get:
3 ( and you run out of numbers )
So you CARRY a (1) ONE into the next column, and reset
the (3 ) three to a Zero, and start counting again.
1 0 Equals ( NOTE 3 + 1 = 0 )
( 10 q, in Decimal, equals our 4 )
Then you start counting again:
10 one 4 + zero 1's = 4 decimal
11 one 4 + one 1's = 5 d
12 one 4 + two 1's = 6 d
13 ( And you run out of numbers)
So you carry a ONE (1) over to the next column, and reset
the ( 3) three to a ZERO ( 0 ), and start counting again.
20 (Which in Decimal, is our 8 )
21 two 4's + one 1's = 8+1= 9 d
22 two 4's + two 1's = 8+2= 10 d
23 ( And you run out of numbers)
So you carry a ONE (1) over to the next column, and reset
the ( 3) three to a ZERO ( 0 ), and start counting again.
Can you guess what the next 9 numbers will be in the
sequence? Try writing them down on paper.**
Here is another analysis of counting numbers and COLUMNS.
In the DECIMAL counting system, when you count to (9), NINE,
you run out of numbers, and you carry a ( 1 ), ONE, into the
next column. This new column in decimal is the " TENS" (10's)
column, and each number is multiplied by ( 10 ) TEN.
When you count to 99, you run out of counting numbers in the
last column, and you carry over a ( 1 ), ONE, into the next
( 10's) TENS column, from the ( first column, the " ONES" ),
and then you run out of numbers in the TENS column, so
you carry over another ( 1 ) ONE into the HUNDREDS column,
and RESET the ( 9 ) NINEs to ZERO ( 0 ).
In ordinary, everyday Decimal, if you read a number like
You are really saying 3 ( Times ONE HUNDREDS )
8 ( times TENs )
4 ( Times ONEs )
3 x 100 + 8 x 10 + 4 x 1
Note that in the ( 10 ) TEN based, DECIMAL system, the
biggest digit is (9) , BUT, the columns that you
carry the ONE ( 1 ) over to, ARE EACH (x 10 ) TIMES TEN.
so that you have:
HUNDREDS, TENS, ONES columns. To get another column,
if you run out of numbers at 999, you multiply the last
column, the 100's column by 10 ( 100 x 10 = 1000 ),
and you get the thousands column.
You then get the columns:
1000 100 10 1
Thousands, Hundreds, Tens, Ones,
(10x10x10x1), (10x 10x1 ), (10x 1 ), (x1)
as each column is TEN times Bigger than the last one.
If I write down that I have " 260 Dollars " in DECIMAL ( 10 )
I have 2 times the HUNDREDS,
plus 6 times TENs,
plus ZERO times ONES.
2 6 0
Hundreds, Tens, Ones,
(10x 10x1 ), (10x 1 ), (x1)
2 x 100 + 6 x 10 + 0 x 1
200 + 60 + 0
This is a total of ( 260 ) Dollars.
In the example of the QUAD ( 4 ) based system, if I say
I have ( 1 2 3 ) dollars, this would be, noting that columns
each are ( 4 ) times bigger than the previous, or
SIXTEENS, FOURS, ONES columns,
( 4x4x1 ) (4x1 ) ( x1 )
123 Dollars =
1 2 3 Dollars
(4x4x1 ) (4x1 ) ( x1 )
16 4 1
I have ONE ( times 16 )
plus 2 ( times 4 )
plus 3 ( times 1 )
EQUALS 16 plus 8 plus 3
EQUALS (27 ) Twenty Seven Dollars in our DECIMAL system.
Lets try another counting system, this time ( 9 ).
The numbers would count from ZERO (0 ) thru (8 )
(Remember, the highest number in a counting system
is ONE LESS than the SYSTEM number - for example,
a 17 NUMBER system would have the highest number
as 16, but each CARRY OVER column, would be 17
times bigger than the previous.)
In a ( 9) NINE based system, you would count:
0, 1, 2, 3, 4, 5, 6, 7, 8 and then run out of counting
numbers. So you carry over from the " ONEs " column,
into the next column, and since this is a ( 9) based system,
the next column is ( TIMES 9 ) or " 9's " column. You then
RESET the 8, to a zero, carry over a ( 1 ) into the next
column ( the 9 times 1 = "9's ) column, and start over
10, 11, 12, 13, 14, 15, 16, 17, 18, and again, run out of
numbers, since there is no number higher than 8.
You reset the 8 to a ( 0 ) ZERO, carry over a ( 1 ) ONE
into the ( 9's ) NINEs column, and keep on counting.
20, 21, 22, 23, 24, 25, 26, 27, 28, and you run out of
numbers again. So you reset the 8 to ( 0 ) ZERO, carry
over a ONE ( 1 ) into the next column, ( the 9's column)
and keep counting, 30, 31, 32, 33, 34, 35, etc.
In this system of NINEs, if I say I have 121 Dollars,
The COLUMNS are each ( 9) NINE times bigger, or
81's column, 9's column, 1's column
(9x9x1) (9x1) (x1 )
1 2 1 dollars
121 (base 9) would be
ONE x 81's, plus 2 x 9's plus 1 x 1's or
(81 ), plus 18, plus 1 =
81 + 18 + 1 = 100 Dollars. ( In our Decimal )
THE BINARY SYSTEM
I f you have paid attention and done the mathematics
above, you will quickly and easily understand BINARY.
Binary is a ( 2 ) number system, so the biggest number you
can count to, is ( 2 ) - 1 = 1.
AGAIN, just like we added 1 + 9 above in the DECIMAL
review above, we now add
1 ( Binary )
1 ( Binary )
WATCH WHAT HAPPENS ! !
YES, 1 + 1 = 0 ( ZERO ) !
Just as we did in adding 9 +1 ( = 0 ) above
we now have to CARRY a (1) ONE into the next
Since this is a TWO (2 ) based system, each column in the
system of CARRY OVER, is ( 2 ) times bigger, so that the
next column is ( 2 ) x 1 = 2, so that the columns are
( 2x1 ) ( x 1 )
and after counting : 0, 1, you RESET the ONE ( 1 ) to ZERO,
and carry over to the ( TWOs ) 2's column.
you now count:
1 0 ( 10 b ( binary ) equals our Decimal 2 )
you then keep counting:
10 , you add a one in the ONEs column,
11, and you run out of counting numbers, so you
RESET the ONEs column 1 to a ZERO, and CARRY over a one
to the TWO's column.
Here, we CARRY a new 1 into the next cloumn
But at this point you have1 plus 1 in the TWOs column, and
since there is no bigger number than ( 1 ) ONE to count to,
you RESET the (1) in the TWO's column to ZERO, and Carry
over a ONE into the next column. Since this is a TWO (2 )
Binary based system, each column is ( 2 ) times as big
as the last one, so the new column would be:
( 2 x 2 x1 )
Giving three columns,
4 2 1
( 2 x 2 x1), (2 x1 ), (x 1 )
and with the third new column of CARRY OVERS, you can
keep on counting:
0 = 0 Decimal
1 = 1 (decimal)
10 = 2 (d)
11 = 3 (d) since 1x2 + 1x1 = 3
100, Now you can add a ONE in the ONEs column.
101, and when you add another ONE in the ONEs
column, you RESET to ZERO, and CARRY
110, Now you can add a ONE in the ONEs column,
111, And Now you run out of numbers in the ONEs
so you ZERO the ONEs, Carry, ZERO the
TWOs, carry, ZERO the FOURs, and carry
GIVING you a new column, ( 2x2x2x1 ) or the EIGHTs column.
1000, Now you can add ONE in the ONEs column,
1001, Zero the One in the ONEs, Carry over to TWOs,
1010, Now you can add ONE in the ONEs column,
1011, Now you have to Zero the ONEs, carry to the
TWO's, Zero the TWO's column, and carry
into the FOUR's column,
1100, and keep counting.
When you reach 1111, you Zero all the ONEs, and Carry into the
fifth new column, the ( 2x 2 x 2 x 2 x1 ) ( or 16's DECIMAL )
column, giving you columns:
16 8 4 2 1
(2x2x2x2x1 ), ( 2x2x2x1), ( 2x2x1), ( 2x1 ), ( x 1)
Now if I say in BINARY, that I have 01010 Dollars, I have:
0 1 0 1 0 dollars
16 8 4 2 1 columns
(2x2x2x2x1 ), ( 2x2x2x1), ( 2x2x1), ( 2x1 ), ( x 1)
0 (times 16s ) plus
1 ( times 8's ) plus
0 ( times 4's ) plus
1 ( times 2's ) plus
0 ( times 1's )
EQUALS 0 +8 + 0 + 2 + 0 = 10 Dollars ( In our Decimal ).
So that in Binary, examples would be:
0001 = ONE (1 ) in Decimal
1000 = EIGHT ( 8) in Decimal
1001 = NINE ( 9 ) in Decimal ( Note 8+1=9)
0010 = TWO ( 2 ) in Decimal
1010 = TEN ( 10 ) in Decimal (Note 8+2=10)
0100 = FOUR ( 4 ) in Decimal
0111 = SEVEN ( 7 ) in Decimal (4+2+1=7)
1 1 1 1
( 1x8 + 1x4 +1x2 + 1x1 )
= 8 + 4 + 2 + 1
= FIFTEEN ( 15 ) Decimal.
(( TRY to read this sentence properly :
There are only 10 kinds of people
- those who know Binary,
and those who do not.))***
8 BIT BINARY
Since " modern" typical computers used 8 bits as
a standard grouping, common numbers inside a
Mailbox, or MEMORY LOCATION, would typically look like:
which, when you have go through thousands of memory
locations BY HAND, writing them all down, is extremely
confusing. It is very easy to make mistakes in copying
row after row of BINARY numbers, particulary when you
know that after the 80-386 and 80-486 typical " IBM"
types of computers, the typical memory group doubled
into 16 BITs of Binary ( 110010110101011 )
and 32 Bits of Binary ( 100010110101011101010100101011)
and now, with the newest chips, it is 64 bit groups, so that
a list of memory locations now looks like:
Do you think you could copy 10,000 lines of these 64 BIT Binary
numbers, and not make a single mistake?
Since everyone DID make mistakes in copying these Binary numbers
over and over again, a system of SHORTHAND, was developed
to turn the confusing mess of ZEROs and ONEs ( 0s and 1s )
into something easier to understand and work with.
HEXADECIMAL SHORTHAND CODES
Since most computers, particulary the 8086 ( the first INTEL chip
of the series ), the 8088 ( a cheaper version of the 8086 released
at a later date, and used by IBM in their first PC computer ),
the 80186 ( a more powerful version of the 8086, NOT used by
IBM but used by many CLONE computers), the 80286
( Known commonly as the " 286 " or " AT " ( Advanced
Technology )), and the 80386, all used the 8 BIT BINARY memory
locations, the common HEXADECIMAL Shorthand developed
in changing the 8 bit BINARY locations into TWO (2 ), CHARACTERS.
HEX is 6 and DECIMAL is 10 ( 6 + 10 = 16 ), so HEXADECIMAL is a
mathematical system with 16 NUMBERS, and you count :
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - hey, I just ran out of characters to count with-
there ARE NO NUMBERS to count with higher than ( 9 ) nine
in our system... How do I write down numbers higher than 9
in a 16 BASED system, when I only have ZERO ( 0 ) to NINE (9)?
What the engineers did was to use LETTERS OF THE ALPHABET,
A, B, C, D, E, and F, to replace the missing numbers,
10, 11, 12, 13, 14, and 15, that do not exist in our DECIMAL system.
So in a 16 ( HEXaDECimal ) based system, the highest number is
( 16 - 1 = 15 ), and you count from ZERO ( 0 ) to ( 15 ) like:
0 =0 ( decimal )
F =15 (decimal )
As it turns out, in BINARY, if you remember from above,
15 (decimal ) in Binary is 1111 ( b inary )
and since an eight digit binary number like 10001010
is TWO GROUPS OF FOUR (4 ), 1000 and 1010,
you can write each of the groups of ( 4 ) FOUR, in
only two HEX (adecimal ) numbers...
FOR EXAMPLE, if an 8 bit binary number is 11110001
this would be two groups -- 1111 and 0001
which in BINARY, would be 1111 (b )= 15 Decimal,
and 0001 (b ) = 1, so you write down the HEX adecimal
Shorthand of ( 15 , 1 ) ( d ecimal )
as ( F , 1 ) in ( HEX or h ).
In order to use this shorthand, you can first change groups
of (4 ) four BINARY DIGITS into DECIMAL, THEN,
you write the HEX (adecimal, or h ) number in place of the
8 BIT MEMORY, at LOCATION 378 ( HEX ), has in it:
First, break the 8 bits into TWO groups of 4:
1010 and 0111
These BINARY GROUPS, in DECIMAL ( from the tables above)
( 10 ) and ( 7 ).
Looking at the table above of HEX, we see that
( 10 ) d (decimal ) is A in HEX, and ( 7 ) d, is ( 7 ) in HEX.
SO that now 10100111 can be written as
Thus, long lists of 8 bit BINARY code like:
can be written in HEX Shorthand as:
which is a LOT easier to write down and to copy,
and to check over long lists to see if there are any mistakes.
The earliest computers that you would use in a home
used a keypad like on a telephone, with the HEXADECIMAL
numbers on them, and when you programmed them, you
typed in lists of HEX, which a tiny program on the computer
changed into 8 Binary bits that the computer would use in its
NOTE: Sometimes you do not have ZEROs at the front of
a binary number. This is the same situation as in every day
decimal. For Example, you would NOT say
" I have ZERO ZERO ZERO twenty six Dollars"
You would just say " I have twenty six dollars".
In Binary, a number might leave OFF the ZEROs at the
front, so that 00000111 may be written as just 111.
To convert to HEXadecimal, you just add the missing
ZEROs at the front, so that you have all 8 characters...
So that 111 becomes 0000 0111, which, in HEX
becomes 0 ( for 0000)
and 7 (for 0111)
THUS, 111 in binary = 07 in HEX, using TWO hex characters.
In the same way, Zero (0) in two digit Hex would be:
0000 0000 as the computer sees the 8 bits, or in HEX,
0000 = 0 and 0000 = 0, so HEX is 00 in 2 digits. This is
the smallest number in two digit HEX, while 1111 1111,
where 1111= F, 1111= F, so the largest two digit Hex
In the programming of a typical robot computer, I
can use BINARY or DECIMAL numbers to put in the "Mailbox"
"Memory" " RAM ( Random access memory) locations.
The BASIC programming language uses HEXadecimal
counting, very often to locate a MEMORY location, so that
instead of saying put 0000 0001 in MEMORY location
0000001101111000, it says put the value ONE (1) in
memory location 378 ( Hex ).
It is a lot easier to say "Put 1 in 378" than to say
"load00000001in0000001101111000". And it is a lot
less confusing. This is why HEX is used a great deal
in typical computing. Note that HEX location 378
is actually a FOUR digit Hex number, 0378, with the
leading zero dropped. To continue counting after you
get to 1111 1111 in binary, or two digit HEX FF, just
keep multiplying the last column by 2 in binary, so that
1111 is 8s, 4s, 2s, and 1s, the next colum would be
16s, then 32's, then 64s, then 128s, then 256s, etc.
256 128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1 1
So that, 100000000 binary is 1x256=256 decimal
110000000 binary is 1x256 + 1x128 = 384 d
100000010 binary is 1x256 + 1x2 = 258 d
HEXadecimal "shorthand" 0378 is
0000 for the first 0
0011 for the 3
0111 for the 7 , and
1000 for the 8.
If you put these together into a SINGLE BINARY, you get:
0000001101111000. IF you remove the leading zeros, you get
1101111000, giving columns:
1 1 0 1 1 1 1 0 0 0 (b)
512, 256, 128, 64, 32, 16, 8, 4, 2, 1 (d)
= 512+256+64+32+16+8 (d)
= 888 in Decimal
= 378 in Hexadecimal
= 1101111000 in Binary
= 1570 in Octal (see below)
You can use this method to find any Binary or Hex number!
There is a built in CALCULATOR in most Windows Systems
that will CONVERT from one counting system to another, but
the Times, Divide, Decimal , and MINUS buttons are ridiculous,
so that I use a FREE calculator with intelligent buttons! To download
the FREE calculator, CLICK HERE.
Numbers used in computing can change from DECIMAL,
to BINARY, to HEXADECIMAL, constantly, so that each
programming language, like BASIC, QBASIC, BASICA,
GWBASIC, etc. uses a way to let you know what number
is being used, and how to ENTER what kind of number in
to the programs. In a textbook, you might find things like
0135 ( h ) for Hexadecimal, or 3120 ( d ) for decimal.
In many BASIC programs, Hexadecimal might be written
as &378H, where the "&H" (Ampersand) sign and H, is used to tell
the computer that the number is in HEX. A great many
of the first computers did NOT use groups of 4 binary
digits, but used 5 digits, 6 digits, 9 digits, 10 digits, 15 digits,
etc., so that the HEX shorthand is not the ONLY one
commonly used today.
OCTAL, or 8 is often used, even
today. Since OCTAL uses base 8, the largest number is
7, or BINARY 111, so that all computers using 3, 6, 9, 15
etc. bits, would group the binary digits in sets of 3, and
use OCTAL Shorthand instead of HEX - You often see the
OCT key on a calculator today.
A computer uses 9 bits instead of 8, so the data looks like:
Which breaks into 3 binary groups, 001 111 and 011
And these binary groups in DECIMAL are 1, 7, and 3,
(( note that in Octal, which has the biggest number as a 7
which is less than Decimal 9, the Octal and Decimal numbers
all appear the SAME - you do not have to use A, B, C, etc. ))
THUS, 001111011, can be written simply in OCTAL shorthand
as 173 (octal )
** ANSWERS to above questions: To continue counting in QUAD,
We so far had, 0, 1, 2, 3, 10,11,12,13, 20,21,22, and 23. At this point
there is no number higher than 3 in a QUAD system, so we ZERO the 3,
and carry, giving, 30,31, 32, 33, and again, zero the 3, and carry, giving
33 +1 =
+1 however, there is no number more than 3, so 3+1 =0, and we
carry the one into a NEW column, the (4x4x1) column, giving us
100 as the next number (= 16d) , and keep counting, 101, 102, 103,
(zero and carry again ) 110, 111, 112, 113, etc.
*** You SAY in English, " There are only TWO kinds of people, those
who know Binary, and those who do not." This is because 10 in BINARY
is TWO, not " TEN".
If you CANNOT see the toolbar with the MENU on the LEFT
side of this page, using a home computer or laptop, or, if you
are on a CELL phone and cannot see or click on the menu at
the top of the screen, then you can, as an option, CLICK HERE
go to the correct HOME PAGE, www.kidbots.com
MATH CLICK HERE
HOW TO CLICK HERE
TYPES CLICK HERE
ROBOT BASIC CLICK HERE
IMAGES CLICK HERE
Robot Cartoons CLICK HERE
Robots CLICK HERE
About kidbots CLICK HERE
Kidbots.com is a Free website, with Free
information, on how to USE Free computers
to make Free ROBOT controllers and
Free ROBOTS for kids.