Binary and Hexadecimal Numbers

[Pages:50]Binary and Hexadecimal Numbers

CSE 1310 ? Introduction to Computers and Programming Vassilis Athitsos

University of Texas at Arlington

1

Decimal Numbers

? A decimal number is an integer written the way we are used to write numbers, using digits from 0 to 9.

? Why do we use 10 digits, and not 2, or 20, or 60, or 150? ? It is a result of:

? Having 10 fingers in our hands, which makes it easier to count up to 10.

? Cultural convention.

2

Babylonian Numbers

? Babylonians used 60 digits instead of 10.

? Make sure you know them for the exam :)

3

Babylonian Numbers

? Babylonians used 60 digits instead of 10.

? Make sure you know them for the exam :) ? In case you are reading this at home: the line above is a

joke!

4

Babylonian Numbers

? Babylonians used 60 digits instead of 10. ? While we do not use that system for writing numbers

today, it has survived in our modern culture. Where? ? In the way we measure time.

? 24 hours. ? 60 minutes. ? 60 seconds.

? Also in the way we measure angles.

? 360 degrees. ? 60 minutes. ? 60 seconds.

5

Binary Numbers

? Computers, in their electronic circuits, essentially use two digits: 1 and 0.

? 1 corresponds to a certain electrical (or magnetic, or optical) signal.

? 0 corresponds to another electrical (or magnetic, or optical) signal.

? This means that we need to represent all numbers using those two digits.

? Numbers represented using 1 and 0 are called binary numbers.

? Java (like any modern programming language) allows us to use decimal numbers.

? Inside the computer, before the program gets executed, all decimal numbers are translated to binary.

6

Binary Numbers

? Since 1310 is our introductory course, it is a good place for you to learn some basics about binary numbers.

? We will do a simplified version. ? We will not worry about representing:

? Floating point numbers. ? Negative numbers.

? We will learn how to represent positive integers in binary.

? We will learn how to translate from binary to decimal and the other way around.

7

Reading a Binary Number

? In general, a binary number is represented like this:

bn-1 bn-2 ... b2 b1 b0

? Each digit bi is either 1 or 0. ? For example, consider binary number 10011.

? What is n?

? What is b0?

? What is b1?

? What is b2?

? What is b3?

? What is b4?

8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download