bits, data types, and operations: chapter 2

16
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP 2610 1

Upload: serina-holder

Post on 30-Dec-2015

23 views

Category:

Documents


2 download

DESCRIPTION

1. Bits, Data types, and Operations: Chapter 2. COMP 2610. Dr. James Money COMP 2610. Floating Point Data Type. Most ISAs have a data type called float , which is 32 bits arranged as follows 1 bit for sign 8 bits for range of exponent 23 bits for the precision or fraction - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Bits, Data types, and Operations: Chapter 2

Bits, Data types, and Operations: Chapter 2

COMP 2610Dr. James Money

COMP 2610

1

Page 2: Bits, Data types, and Operations: Chapter 2

Floating Point Data Type

Most ISAs have a data type called float, which

is 32 bits arranged as follows– 1 bit for sign

– 8 bits for range of exponent

– 23 bits for the precision or fraction

This is called the IEEE Standard for Floating

Point Arithmetic

Page 3: Bits, Data types, and Operations: Chapter 2

Floating Point Data Type

Page 4: Bits, Data types, and Operations: Chapter 2

Floating Point Data Type

Recall the bits in the fractional part are of the

form

1.b-1b-2…b-j

The corresponding decimal number is

1x20 + b-1x2-1+b-2x2-2+… + b-j 2-j

Page 5: Bits, Data types, and Operations: Chapter 2

Floating Point Data Type

If the exponent=00000000, then we can

represent tiny numbers.

In this case, we assume the leading digit is

zero and not 1 and exp=-126. That is, it is of

the form

-1s 0.fraction x 2-126

Page 6: Bits, Data types, and Operations: Chapter 2

Floating Point Data Type

Consider the floating point value

0 00000000 0000100000000000000000

This is

+ 2-5 x 2-126 = 2-131

Page 7: Bits, Data types, and Operations: Chapter 2

Floating Point Data Type

Interpret the floating point values

– 0 11111110 1111111111111111111111

– 1 00001101 0111000000000000000000

– 1 00000000 0000000000001000000000

Page 8: Bits, Data types, and Operations: Chapter 2

ASCII Codes

Another standard of representation is one for

transferring character codes

This is an eight bit code referred to ASCII

ASCII stands for American Standard Code for

Information Exchange

It simplifies the interface between I/O devices

among companies

Page 9: Bits, Data types, and Operations: Chapter 2

ASCII Codes

Each key on a keyboard is identified by a

unique ASCII code

The digit 3 is (00110011)2 = (41)10, digit 3 is

(00110010)2 = (40)10

The letter ‘e’ is (01100101)2 and carriage

return is (00001101)2

Page 10: Bits, Data types, and Operations: Chapter 2

ASCII Codes

The list of codes are at the back of the book

for all 256 ASCII codes

Some codes are associate with multiple

keys, such as ‘e’ and ‘E’

Page 11: Bits, Data types, and Operations: Chapter 2

Hexadecimal Notation

One form that is common for reading values

on the computer is called hexadecimal

notation

Hexadecimal notation is the base 16

representation of the number

Page 12: Bits, Data types, and Operations: Chapter 2

Hexadecimal Notation

We use 0-9 for the same numbers in

hexadecimal

What about 10-15?

We use the letters A-F

Page 13: Bits, Data types, and Operations: Chapter 2

Hexadecimal Notation

A – 10

B – 11

C – 12

D – 13

E – 14

F - 15

Page 14: Bits, Data types, and Operations: Chapter 2

Hexadecimal Notation

Consider the binary string

0011110101101110

This can be broken into groups of 4 bits:

0011 1101 0110 1110

Now, recall that the range of 4 bits is 0 -15,

just like hexadecimal notation

Page 15: Bits, Data types, and Operations: Chapter 2

Hexadecimal Notation

Hence, the numbers represent

We typically prefix this by x or 0x to indicate

hexadecimal form

So our binary number is 0x3D6E

0011 1101 0110 1110

3 13 6 14

3 D 6 E

Page 16: Bits, Data types, and Operations: Chapter 2

Hexadecimal Notation

What is the number 0x5A6C in binary form?

Thus, (5A6C)16 = (0101 1010 0110 1100)2

5 A 6 C

5 10 6 12

0101 1010 0110 1100