computer arithmetic: binary, octal and hexadecimal presented by frank h. osborne, ph. d. © 2005 id...

24
Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Post on 22-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Computer Arithmetic:

Binary, Octal and Hexadecimal

Presented byFrank H. Osborne, Ph. D.

© 2005

ID 2950Technology and the Young Child

Page 2: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Bits and Bytes

• A bit is a binary digit.

• A bit is like a light switch. It has two positions, off = 0 and on = 1.

Page 3: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Bits and Bytes

• A byte is like a row of 8 switches.

Page 4: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Bits and Bytes

• Because it has only two digits, 0 and 1, the binary number system is base 2.

• We are accustomed to using base 10 which has 10 digits which are as follows:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

• Computers work in base 2 while we work in base 10.

Page 5: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Review of Base 10

• Consider the number 3178.

• 3 is the thousands place = 3000 = 3 x 103

• 1 is the hundreds place = 100 = 1 x 102

• 7 is the tens place = 70 = 7 x 101

• 8 is the units place = 8 = 8 x 100

Page 6: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Review of Base 10

• Each numeral is multiplied by 10 raised to the appropriate power for its position.

Page 7: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Review of Base 2

• A byte is 8 bits which are like 8 switches.

Page 8: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Properties of Base 2• Each numeral is multiplied by 2 raised to the

appropriate power for its position.

• So, a byte can hold a number between 0 and 255.

Page 9: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Converting Base 2 Numbers to Base 10

• What is the value of 0100 1001 in base 10?

• The answer is 73.

Page 10: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

• To solve this type of question, remember the sequence of positions.

• The values are in the following sequence:

1, 2, 4, 8, 16, 32, 64, 128

• Find which switches are on and add the values together.

Page 11: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Octal is Base 8

• If we take the bits by threes, we get octal, which is base 8.

• The base 8 numerals are:

0, 1, 2, 3, 4, 5, 6, 7The positions for the octal digits are:

000 = 0 100 = 4

001 = 1 101 = 5

010 = 2 110 = 6

011 = 3 111 = 7

Page 12: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Use of Octal

• Some computers actually use octal for calculations but it is a big problem because the 8-bit byte is not evenly divisible by 3.

• Octal us used for setting the UNIX access rights to directories on server computers.

• You will use this for sure if you are putting things into a directory on a server for use on the Internet.

Page 13: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Setting UNIX Access Rights

• UNIX access rights are assigned to every file and directory on the server.

• Rights have the form: drwxrwxrwx– d means if it is a directory or not– r means read– w means write– x means execute

• There are three sets of rwx rights. These are for you, for those in your group and for everyone else. Each letter is one bit.

Page 14: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Setting UNIX Access Rights

• On the Kean turbo server, a faculty member may have an account.

• All other faculty are in the same group.

• Anyone from the outside, such as on the World Wide Web, can have access if the rights are set correctly.

Page 15: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Setting UNIX Access Rights

• drwxrwxrwx - The first set of bits is for yourself. You want to be able to read, write, create, delete or alter your file without any problems. Use octal 7 = 111 to set this part.

• drwxrwxrwx - This is for your group--the other users at your place. Unless you want someone monkeying with your files, let them have read-only (100 = 4) which makes it r--. If you do not want them to know it is there, set it to 000 = 0, which makes it ---.

Page 16: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Setting UNIX Access Rights

• drwxrwxrwx - The last set of bits is for everybody else.

• For your Internet pages, make a directory called www and set the access rights to 100 which makes it read-only. The server will let anyone on the Internet read the contents, but they will not be able to delete or change anything.

• So, your www directory is set as 447 which corresponds to dr--r--rwx.

Page 17: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Hexadecimal is Base 16

• If we take the bits by fours, we get hexadecimal, which is base 16.

• The base 16 numerals are:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F• As base 10 does not have single numerals for the numbers

from 10-15 we use A-F.

Page 18: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Table of Binary and Hex Equivalents

Page 19: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Properties of Hexadecimal

• A hexadecimal number is exactly one-half of a byte.

• Since a byte can be from 0-255 in decimal, it also can be from #00 to #FF in hexadecimal.

• Use the pound sign (#) as a prefix for hexadecimal numbers.

• Binary and hexadecimal numbers carry to the other half of the same byte at the same time.

Page 20: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Uses of Hexadecimal

• On the Internet, documents are written in HTML, the hypertext markup language.

• All colors on computers are a combination of three colors; red, blue and green; known as RGB.

• In HTML, you set the values of RGB using hexadecimal numbers.

• The form for a color is: #RRGGBB

Page 21: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

Some Hexadecimal HTML Color Codes

Page 22: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

More about Hexadecimal Color Codes

• With #RRGGBB, each can have a value from 0 to 255. This gives:

256 x 256 x 256 = 16, 777, 216 different possible colors.

• The most commonly used hex values are:

#00, #33, #66, #99, #CC, and #FF. These give a total of 216 colors.

• Find Dave Taylor's list at the following url:

www.intuitive.com/coolsites/colors.html

Page 23: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

ASCII Codes

• ASCII stands for American Standard Code for Information Interchange.

• ASCII values range from 0 to 255.– Values 0 through 31 - control characters– 32 through 47 are special keyboard characters– 48 through 64 are numerals and characters– 65 through 96 capital letters and characters– 97 through 127 lower case letters and

characters– 128 through 255 special characters

Page 24: Computer Arithmetic: Binary, Octal and Hexadecimal Presented by Frank H. Osborne, Ph. D. © 2005 ID 2950 Technology and the Young Child

The End