Presentation is loading. Please wait.

Presentation is loading. Please wait.

How Computers Represent Information Yong Choi School of Business CSU, Bakersfield.

Similar presentations


Presentation on theme: "How Computers Represent Information Yong Choi School of Business CSU, Bakersfield."— Presentation transcript:

1 How Computers Represent Information Yong Choi School of Business CSU, Bakersfield

2 Digital Storage Humans: decimal (or base 10) number system Computer: binary (base 2) number system On (“high” or 1) Off (“low” or 0) Each digit in a binary number is known as a bit and can have only one of two values, 0 or 1. One bit can store a number from 0 to 1 Two bits can store from 0 to 3 n bits can store numbers from 0 to 2 n

3 Binary Numbers Programmers often need to read numbers in the computer because the number of bits in calculation affects the accuracy and size limitations of numbers manipulated by the computer. So, it is useful to understand how the binary number system is used within the computer. In Java, programmer can declare a variable to be short (16 bits) and or long (64 bits) integer depending on the anticipated size of the number being used and required accuracy in calculations.

4 Advantages of Binary Numbers Simple Only two O and 1 Unambiguous and clear signals Analog signal vs. Digital signal Flawless copies can be made Anything (English, Spanish, Chinese) can be represented with patterns of bits

5 Hexadecimal Numbers Important!! Because it is commonly used as a shorthand notation for binary numbers. Each hexadecimal number exactly represent 4 binary bits. Most computers store and manipulate instructions and data using word sizes that are multiple of 4 bits. Colors in VB can be specified as a six-digit hexadecimal number. http://www.mrs.umn.edu/committees/wwwac/tool box/color.html http://www.mrs.umn.edu/committees/wwwac/tool box/color.html

6 Review of Decimal Numbers Decimal numbers are based on powers of 10. Mathematically, the number 537 can be calculated.. Similarly 9238 is 9 10 3 + 2 10 2 + 3 10 1 + 8 10 0 5 10 2 3 10 1 7 10 0 5 1003 107 1 500307

7 Converting Binary to Decimal Easy, just multiply digit by power of 2 Binary numbers are based on power of 2. Just like a decimal number is represented So, 101 binary is 1 2 2 + 0 2 1 + 1 2 0 = 5 or 1 4 + 0 2 + 1 1 = 5

8 Binary to Decimal Example 76543210 2727 2626 2525 2424 23232 2121 2020 1286432168421 10011100 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156 2 7 *1 + 2 6 *0 …………….. What is 10011100 in decimal?

9 Converting Decimal to Binary A little more work than binary to decimal Find largest power-of-two smaller than decimal number Make the appropriate binary digit a ‘1’ Subtract the power of 2 from decimal Do the same thing again Some examples 3 = 2 + 1 = 11 (that’s 12 1 + 12 0 ) 5 = 4 + 1 = 101 (that’s 12 2 + 02 1 + 12 0 )

10 Decimal to Binary Example Convert 28 decimal to binary 28/2 = 12 ……. 0 12/2 = 10 ……. 0 10/2 = 5 ……… 0 5/2 = 4 ……….. 1 4/2 = 2 ……….. 0 2/2 = 1 ……….. 0 Answer: 1001000

11 Converting Hex to Binary Hexadecimal table DecBinHex 000000 100011 200102 300113 401004 501015 601106 701117 DecBinHex 810008 910019 101010a 111011b 121100c 131101d 141110e 151111f

12 Hex to Binary Example 0010 Hex to Binary – just convert digits 10101100 2ac = 001010101100 No magic!! - remember each hex digit = 4 bits 2ac

13 Binary to Hex Just convert groups of 4 bits 101001101111011 1011 537b 101001101111011 = 537b 0101  0111  0011 

14 Hex to Decimal Just multiply each hex digit by decimal value, and add the results.  16 3 16 2 16 1 16 0 4096256161 2ac 2 256 + 10 16 + 12 1 = 684 DecHex 00 11 22 33 44 55 66 77 88 99 10a 11b 12c 13d 14e 15f

15 Decimal to Hex Analogous to decimal  binary. 1. Find largest power-of-16 smaller than decimal number 2. Divide by power-of-16. The integer result is hex digit. 3. The remainder is new decimal number. 4. Do the same thing again

16 Decimal to Hex  16 3 16 2 16 1 16 0 4096256161 DecHex 00 11 22 33 44 55 66 77 88 99 10a 11b 12c 13d 14e 15f 684 684/256 = 2 2__ 684/256 = 172 172/16 = 10 = a 2a_ 172/16 = 12 = c 2ac

17 Exercise Questions Convert decimal value 110 to Binary Hexadecimal Convert binary value 1100111 to Decimal Hexadecimal Convert hexadecimal value 6CAD to Decimal Binary


Download ppt "How Computers Represent Information Yong Choi School of Business CSU, Bakersfield."

Similar presentations


Ads by Google