1 / 17

How Computers Represent Information

How Computers Represent Information. Yong Choi School of Business CSU, Bakersfield. Digital Storage. Humans: decimal (or base 10) number system Computer: binary (base 2) number system On (“high” or 1) Off (“low” or 0)

armani
Télécharger la présentation

How Computers Represent Information

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 2n

  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/toolbox/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 • 103 + 2 • 102 + 3 • 101 + 8 • 100

  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 • 22 + 0 • 21 + 1 • 20 = 5 or 1 • 4 + 0 • 2 + 1 • 1 = 5

  8. Binary to Decimal Example What is 10011100 in decimal? 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156 27 *1 + 26 *0 ……………..

  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 1•21 + 1•20) • 5 = 4 + 1 = 101 (that’s 1•22 + 0•21 + 1•20)

  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

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

  13. 5 3 7 b Binary to Hex • Just convert groups of 4 bits 101001101111011 0101  0011  0111  1011 101001101111011 = 537b

  14. Hex to Decimal • Just multiply each hex digit by decimal value, and add the results. 2ac 2 • 256 + 10 • 16 + 12 • 1 = 684

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

  16. Decimal to Hex 684 2__ 684/256 = 2 684/256 = 172 2a_ 172/16 = 10 = a 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

More Related