Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Information Technology

Similar presentations


Presentation on theme: "Introduction to Information Technology"— Presentation transcript:

1 Introduction to Information Technology
BINARY REPRESENTATION OF REAL NUMBERS AND TEXT HEXADECIMAL AND OCTAL Lecture Notes - 2

2 Topics Representing “Real Numbers” in Binary
Representing Negative Numbers in Binary Representing Text in Binary Determining How Many Bits are Needed to Represent Something Octal and Hexadecimal Numbering Systems

3 Representing Real Numbers in Bits
We’ve learned how to represent integers in binary form. Real numbers can also be represented in binary. We will illustrate this using thermometer measurements as an example. A mercury thermometer reflects temperature that can continuously vary over its range of measurement (an analog device). A digital thermometer would require an infinite number of bits to accomplish the same thing. If we are building a digital thermometer, we must make some choices and determine some parameters: Precision (number of bits we will use) v. cost Accuracy (how true is our measurement against a given standard).

4 CONTINUOUS VS. DISCRETE FUNCTIONS
Recall that mercury thermometer measurements are a continuous function: there is an infinite number of points making up that function. Discrete functions have a finite number of values.

5 FUNCTIONS In mathematics, a function is an association between two sets of values in which each element of one set has one assigned element in the other set so that any element selected becomes the independent variable and its associated element is the dependent variable. Thus, in: y = f(x) y is said to be a function of x. Common functions we might deal with: Functions of Time Functions of Space Functions of Frequency Functions of Power Usually, functions are represented as a relationship on an x-y axis graph.

6 THE SINE WAVE IS A FUNCTION

7 REPRESENTING REAL NUMBERS
Using temperature values as an example: What is the range we wish to measure? How many values do we need to provide adequate precision? How many bits are we willing to allocate? Suppose we want to represent a range of temperature measurements between 60-70oF There is an infinite number of possible different temperature readings between 60-70oF Let’s decide that 256 different temperature values between would give us more than enough precision. An 8-bit code would provide these values. Why 8 bits? 70-60 256 = oF The 256 temperatures we can represent are separated by .039

8 CONVERTING TEMPERATURE INTO BITS
We can use the 8-bit word to encode the following values: Binary Codeword Temperature, oF . .

9 ANOTHER TEMPERATURE EXAMPLE
Suppose we want to read the thermometer to the hundredth of a degree between the values of -40 and +140oF. How many bits are required? 180 x 100 = steps Can implement with a 15 bit code (215 = 32768) Note “wasted” bits Precision now: to the hundredth degree Is a precise instrument the same as an accurate one? How do we build the code now?

10 THERMOMETER CODING - ONE METHOD

11 THERMOMETER CODING (ANOTHER METHOD)

12 WHAT WAS THAT? 2'S COMPLEMENT NOTATION
The most common way to represent negative number is using “2’s Complement Notation.” Take the positive binary representation with the MSB as a sign bit (a 0 makes the representation positive) 01001 (+910) Take the binary complement (flip the bit values) 10110 Add a binary 1 = (-910)

13 2’S COMPLEMENT NOTATION
Express the decimal number -5 in 5-bit binary notation. First determine the 5-bit binary representation of 5: 00101 Then complement (change 1s to 0s and 0s to 1s) each bit: 11010 Finally, add 1: 11011 -5 = in 2’s complement notation (To reverse the process take the complement and add 1!) Note that the 2’s complement of a 2’s complement of a number equals the original number.

14 IN-CLASS PROBLEMS

15 How Can Alphanumeric Symbols be Represented in Binary Code?
ASCII American Standard Code for Information Interchange The computer translates each typed character into a 7 (or 8) bit binary code. For example, Information is entered via a keyboard. For example “Hi” How does the computer determine that “Hi” should be translated into ? It uses a code, ASCII, which specifies by agreed upon convention, a unique 7 or 8 bit combination for each alphanumeric character.

16 About ASCII ASCII is a fixed length code, meaning it uses the same number of bits to represent all possible symbols produced by the source. ASCII can represent 128 symbols (27 symbols) and Extended ASCII can represent 256 symbols (28 symbols). Computer memories are usually structured in 8-bit units (bytes). It is convenient to represent alphanumeric symbols with a single byte for storing text, so ASCII usually uses 7 bits plus an “extended” bit.” This is called “Extended ASCII.” Appendix A in the text contains an ASCII key, which specifies a decimal, hexadecimal, and binary code for each alphanumeric character. Using the ASCII key, how would we translate IT 101 into decimal or binary code? Let’s look at the ASCII key….

17 Sample ASCII Chart

18 ASCII Encoding Example
Using the ASCII key in Appendix A of the textbook, p. 313 (this key uses 7-bit binary ASCII format) How would we encode INFT 101 into decimal and ultimately binary? Char. Dec Binary I = 73 = N = 78 = F = 70 = T = 84 = space = 32 = 1 = 49 = 0 = 48 = The ASCII Key Tells Us That: INFT 101 =

19 ASCII Decoding Example
Decode this binary sequence: One option is to break it down into bytes, translate into decimal numbers, and look up on ASCII chart: C h a p t e r

20 How Many Bits Are Necessary to Represent Something?
1 bit can represent two (21) symbols either a 0 or a 1 2 bits can represent four (22) symbols 00 or 01 or 10 or 11 3 bits can represent eight (23) symbols 000 or 001 or 011 or 111 or 100 or 110 or 101 or 010 4 bits can represent sixteen (24) symbols 5 bits can represent 32 (25) symbols 6 bits can represent 64 (26) symbols 7 bits can represent 128 (27) symbols 8 bits (a byte) can represent 256 (28) symbols n bits can represent (2n) symbols! So…how many bits are necessary for all 102 of us in class to have a unique binary ID?

21 Question Is 64-bit twice as big as 32-bit?
32 bit = 232 = 4,294,967,296 bits 64 bit = 264 = 1.8 x 1019 bits 128 bit = 2128 = 3.4 x 1038 bits Is 8-bit twice as big as 4-bit? 8 bit = 28 = 256 bits 4 bit = 24 = 16 bits Remember that we’re dealing with exponents! 8 bit is twice as big as __________? 7 bit! 7 bits provide 27 possible values or 2x2x2x2x2x2x2 = 128 8 bits provide 28 possible values or 2x2x2x2x2x2x2x2 = 256

22 Something to Remember Transmission Rates Measured in Bits Per Second “Bits” are often used in terms of a data rate, or speed of information flow: 56 Kilobit per second modem (56 Kbps) A T-1 is Megabits per second (1.544 Mbps or 1544 Kbps) “Bytes” are often used in terms of storage or capacity--computer memories are organized in terms of 8 bits 256 Megabyte (MB) RAM 40 Gigabyte (GB) Hard disk Computer Storage and Memory Measured in Bytes

23 Note! The Multipliers for Bits and Bytes are Slightly Different.
“Kilo” or “Mega” have slightly different values when used with bits per second or with bytes. When Referring to Bytes (as in computer memory) Kilobyte (KB) = 1,024 bytes Megabyte (MB) 220 = 1,048,576 bytes Gigabyte (GB) = 1,073,741,824 bytes Terabyte (TB) = 1,099,511,627,776 bytes When Referring to Bits Per Second (as in transmission rates) Kilobit per second (Kbps) = 1000 bps (thousand) Megabit per second (Mbps) = 1,000,000 bps (million) Gigabit per second (Gbps) = 1,000,000,000 bps (billion) Terabit per second (Tbps) = 1,000,000,000,000 bps (trillion)

24 More Multipliers for Measuring Bytes
Kilobyte (K) = 1,024 bytes Megabyte (M) 220 = 1,048,576 bytes Gigabyte (G) = 1,073,741,824 bytes Terabytes (T) 240 = 1,099,511,627,776 bytes Petabytes (P) 250 = 1,125,899,906,842,624 bytes Exabytes (E) = 1,152,921,504,606,846,976 bytes Zettabytes (Z) 270 = 1,180,591,620,717,411,303,424 bytes Yottabytes (Y) 280 = 1,208,925,819,614,629,174,706,176 bytes

25 New Topics The Octal Numbering System:
What is It and When Would We Use It? The Hexadecimal Numbering System: Converting between Binary, Octal, and Hexadecimal

26 Alternative Notations - Octal and Hexadecimal Representation
When dealing with collections of bits - for example binary words representing text characters using the ASCII code - it can be inconvenient to deal with each individual bit. Sometimes it’s necessary to examine particular bit patterns to determine whether a system is operating properly. For such applications, we find it easier to use a “shorthand” notation, or alternative notation. Two examples are “octal” and “hex” Octal--base 8--Uses 8 Numerals 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal--base 16--Uses 16 Numerals 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

27 Octal A counting system using the first eight numerals starting with zero. So the first 20 numbers of this system are: 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23 Because each numeral can only take on one of 8 values, and because 8 is a power of 2, we can use an octal numeral as shorthand to represent a group of 3 bits: Octal Numeral Bit Pattern 0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111

28 Converting Binary to Octal
For example, the number may be converted to octal form by grouping the bits into 3. Starting from the right, break the bit pattern into groups of three: The first 3-bits are: 111, corresponding to 7. The next 3-bits are: 010, corresponding to 2. The next are 001, corresponding to 1. and the last 3-bits are 101, corresponding to 5. The above binary number may be represented by: 5127(8) in octal form

29 Octal Example If the following 12-bit pattern is stored in a computer’s memory: (2) We can represent these bits in octal as: 2635(8)

30 In-Class Problems: Binary to Octal Conversion
Convert to octal: (2) (2)

31 In-Class Problems: Octal to Binary Conversion
Convert to binary: 63(8) 215(8) Could we convert 291?

32 Hexadecimal The “Hex” system uses 16 numerals:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F What are the first 20 numbers of the hex system? 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13 Because each numeral can take on one of 16 values, and because 16 is another power of two, we can use a hex numeral to represent a grouping of four bits.

33 Comparing Decimal, Octal, Hex, Binary
Decimal Octal Hex Bit Pattern A 1010 B 1011 C 1100 D 1101 E 1110 F 1111

34 Converting Binary to Hexadecimal
For example, the number (2) may be converted to hexadecimal form by grouping the bits into 4 and translated as follows: Starting from the right, count 4 digits to the left. The first 4-bits are: 0111, corresponding to 7(16). The next 4-bits are: 1101, corresponding to D(16). The last bits are: 1010, corresponding to A(16) The above binary number may be represented by: AD7(16) in hexadecimal form

35 In-Class Problems Convert to Hex: (2)

36 In-Class Problems Convert to Hex: (2)

37 In-Class Problems Convert to Binary: ADD1(16)

38 Converting Octal and Hex to Decimal
To convert octal and hex to decimal, we apply the same technique as converting binary to decimal. Remember that we summed together the weights of the various positions in the binary number which contained a “1” to convert from binary to decimal. Similarly, we sum the weights of the various positions in the octal or hex numbers depending on the base being used. Binary is base 2 Octal is base 8 Hex is base 16 Example of octal to decimal conversion..

39 Real World Hexadecimal Examples
Important In-Class Examples Ethernet Addresses Internet Addresses (IPv6)


Download ppt "Introduction to Information Technology"

Similar presentations


Ads by Google