Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP 2610 1."— Presentation transcript:

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

2 Bit Vectors There are many occasions when you want to store independently whether a particular part of a system is busy or available For example, consider tracking whether a particular taxicab at a company is in use

3 Bit Vectors To do this, assume we have n units to keep track We can use a single bit for each unit, thus requiring n bits This is called a bit vector We arbitrarily assume what 0 and 1 represent

4 Bit Vectors Suppose we have 8 machines to monitor with respect to their availability with a 8 bit BUSYNESS bit vector Here, 1=unit is free, 0=unit is busy Bits are labeled right to left, 0 to 7

5 Bit Vectors Suppose BUSYNESS is 11000010 What does this mean? What work is assigned to unit 7 What is the new bit vector? How do we use a logical operation to do this?( AND 01111111)

6 Bit Vectors Suppose unit 5 finishes it’s task We need to update the BUSYNESS vector so that unit 5 is free How do we do this with a logical operation?

7 Precision We’ve used 16 bit values to represent our range of integers With 16 bits, we can represent 0 to 65535 or -32768 to 32767 in signed values That is, the range of values is -2 15 …2 15 -1

8 Precision For this case, we say the precision of the data type is 15 bits and the range is 2 15 In general, for n bits our signed range is -2 n-1 …2 n-1 -1 This corresponds to a precision of n-1 bits and a range of 2 n-1

9 Floating Point Data Type So far, we have only learned how to store integers on the computer What if we want to store the number 2.73? We have to use the floating point data type We do not use the entire 16 bits to store the precision of the value But we do not have enough of a range!

10 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

11 Floating Point Data Type

12 Note the exponent is not allowed to be either 0 or 255 These are special cases for the numbers This is similar to scientific notation Recall normalized scientific numbers are in the form A x 10 p where 1<=A<10

13 Floating Point Data Type Consider the number 3.75 First convert the number to binary form – We have (3) 10 = (11) 2 Now, how about 0.75 part? We can convert this by multiplying by 2(instead of dividing) This moves the decimal one space to the right

14 Floating Point Data Type 0.75x2 = 1.50 Truncate the whole part and repeat: 0.50x2 = 1.00 0.00x2 = 0.00 … So our bits are (11.1100…) 2

15 Floating Point Data Type Now we move the decimal to the left, to get it in the correct form 1.xxxx: 11.1100 = 1.11100 x 2 1 So we have S=0, exponent = 127+1=128 = (10000000) 2, fraction=(111 0000 0000 0000 0000 0000) 2 FP Value = 0100 0000 0111 0000 0000 0000 0000 0000

16 Floating Point Data Type What does the floating point data type 0011 1101 1000 0000 0000 0000 0000 0000 represent? S=0, positive Exponent = (011 1101 1) 2 = 123 So, the power is 2 123-127 =2 -4

17 Floating Point Data Type Fraction = 1.000 0000 0000 0000 0000 0000 Thus, our number is – 1 x 2 -4 – Or 1/16


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

Similar presentations


Ads by Google