1 / 41

Lecture 2 Number Systems

Lecture 2 Number Systems. Introduction to Information Technology. Dr. Ken Tsang 曾镜涛 Email: kentsang@uic.edu.hk http://www.uic.edu.hk/~kentsang/IT/IT3.htm Room E408 R9. Get slides from:.

brandy
Download Presentation

Lecture 2 Number Systems

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. Lecture 2Number Systems Introduction to Information Technology Dr. Ken Tsang 曾镜涛 Email:kentsang@uic.edu.hk http://www.uic.edu.hk/~kentsang/IT/IT3.htm Room E408 R9

  2. Get slides from: The glossary and PDF version of the slides are here: http://www.uic.edu.hk/~davetowey/teaching/CS/it1010/lectures/2.Glossary.pdfhttp://www.uic.edu.hk/~davetowey/teaching/CS/it1010/lectures/2.Number.Systems.pdfhttp://www.uic.edu.hk/~davetowey/teaching/CS/it1010/lectures/2x2_2.Number.Systems.pdf

  3. Outline • Decimal Number System • Binary Number System • Hexadecimal Number System • Positional Numbering System • Conversions Between Number Systems • Conversions Between Power-of-Two Radices • Bits, Bytes, and Words • Basic Arithmetic Operations with Binary Numbers

  4. Natural Numbers • Natural numbers • Zero and any number obtained by repeatedly adding one to it • Negative Numbers • A value less than 0, with a – sign • Integers • A natural number, a negative number, zero • Rational Numbers • An integer or the quotient of two integers • We will only discuss the binary representation of non-negative integers

  5. Decimal Number System • A human usually has four fingers and a thumb on each hand, giving a total of ten digits over both hands • 10 digits: • 0,1,2,3,4,5,6,7,8,9 • Also called base-10 number system, • Or Hindu-Arabic, or Arabic system • Counting in base-10 • 1,2,…,9,10,11,…,19,20,21,…,99,100,… • Decimal number in expanded notation • 234 = 2 * 100 + 3 * 10 + 4 * 1

  6. Binary Number System • Binary number system has only two digits • 0, 1 • Also called base-2 system • Counting in binary system • 0, 1, 10, 11, 100, 101, 110, 111, 1000,…. • Binary number in expanded notation • (1011)2 = 1*23+ 0*22+ 1*21+ 1*20 • (1011)2 = 1*8 + 0*4 + 1*2 + 1*1 = (11)10

  7. Gottfried Leibniz (1646-1716) Leibniz, the last universal genius, invented at least two things that are essential for the modern world: calculus, and the binary system. He invented the binary system around 1679, and published in 1701. This became the basis of virtually all modern computers.

  8. Leibniz's Step Reckoner • Leibniz designed a machine to carry out multiplication, the 'Stepped Reckoner'. It can multiple number of up to 5 and 12 digits to give a 16 digit operand. The machine was later lost in an attic until 1879.

  9. An ancient Chinese binary number system in Yi-Jing (易经) • Two symbols to represent 2 digits • Zero: represented by a broken line • One: represented by an unbroken line • “—” yan 阳爻,“--” yin 阴爻。

  10. Hexadecimal • Hexadecimal number system has 16 digits • 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F • Also called base-16system • Counting in Hexadecimal • 0,1,…,F,10,11,…,1F,20,…FF,100,… • Hexadecimal number in expanded notation • (FF)16 = 15*161+ 15*160 = (255)10

  11. Some Numbers to Remember

  12. Positional Numbering System • The value of a digit in a number depends on: • The digit itself • The position of the digit within the number • So 123 is different from 321 • 123: 1 hundred, 2 tens, and 3 units • 321: 3 hundred, 2 tens, and 1 units

  13. Base r Number System • r symbols • Value is based on the sum of a power series in powers of r • r is called the base, or radix

  14. The Octal System (base 8) • Valid symbols: 0,1,2,3,4,5,6,7 1. 268 = ? Questions: 2.How to count in Octal?

  15. Why Binary? • A computer is a Binary machine • It knows only ones and zeroes • Easy to implement in electronic circuits • Reliable • Cheap

  16. Bit and Byte • BIT = Binary digIT, “0” or “1” • State of on or off ( highorlow) of a computer circuit • Kilo 1K = 210 = 1024 ≈ 103 • Mega 1M = 220 = 1,048,576 ≈ 106 • Giga 1G = 230 = 1,073,741,824 ≈ 109

  17. Bit and Byte • Byte is the basic unit of addressable memory • 1 Byte = 8 Bits • The right-most bit is called the LSB Least Significant Bit • The Left-most bit is called the MSB Most Significant Bit

  18. Why Hexadecimal? • Hexadecimal is meaningful to humans, and easy to work with for a computer • Compact • A BYTE is composed of 8 bits • One byte can thus be expressed by 2 digits in hexadecimal • 11101111  EF • 11101111b EFh • Simple to convert them to binary

  19. Conversions Between Number Systems • Binary to Decimal

  20. Conversions Between Number Systems • Hexadecimal to Decimal

  21. Conversions Between Number Systems • Octal to Decimal • (32)8 = (?)10 • What’s wrong? • (187)8 = 1*64 + 8*8 + 7*1

  22. quotient remainder 321 / 2 = 160 1 160 / 2 = 80 0 80 / 2 = 40 0 40 / 2 = 20 0 20 / 2 = 10 0 10 / 2 = 5 0 5 / 2 = 2 1 2 / 2 = 1 0 1 / 2 = 0 1 Conversions Between Number Systems • Decimal to Binary 32110 = ?2 Reading the remainders from bottom to top, we have 32110 = 1010000012

  23. One More Example Convert 14710 to binary So, 14710 = 100100112

  24. Conversions Between Number Systems • Decimal to Base r • Same as Decimal to Binary • Divide the number by r • Record the quotient and remainder • Divide the new quotient by r again • ….. • Repeat until the newest quotient is 0 • Read the remainder from bottom to top

  25. Exercises Please show your steps of conversion clearly. • Convert 19910 to binary • Convert 25510 to binary • Convert 25510 to hexadecimal • Convert 2558 to decimal • Convert 12316 to decimal

  26. Conversions Between Power-of-2 Radices • Because 16 = 24, a group of 4 bits is easily recognized as a Hexadecimal digit • And a group of 3 bits is easily recognized as one Octal digit • To convert a Hex or Octal number to a binary number Represent each Hex or Octal digit with 4 or 3 bits in binary

  27. Conversions Between Power-of-2 Radices Convert a binary number to Hex or Oct number

  28. Basic Arithmetic Operations with Binary Numbers • Rules for Binary Addition • 1+1=0, with one to carry to the next place

  29. Example

  30. Example

  31. Basic Arithmetic Operations with Binary Numbers • Rules for Binary Subtraction • 1 - 0 = 1 • 1 - 1 = 0 • 0 - 0 = 0 • 0 - 1 = 1 … borrow 1 from the next most significant bit

  32. Example minuend subtrahend difference

  33. Two’s Complement • Alternative way of doing Binary Subtraction • Invert the digits (of the subtrahend) • 0001 0001  1110 1110 • Add 1 • 1110 1110  1110 1111 • Add this to the minuend • 1110 1111 + 0010 0101 = 1 0001 0100 • Drop/Ignore the MSB • 0001 0100

  34. Why “Two’s Complement” works? • Suppose A = 1001001 a 7-bit binary minuend • B = 0011011 a 7-bit binary subtrahend • Want to calculate the difference C = A – B • Rewrite C = A + (1111111 – B ) +1 – 1000000 • D = 1111111 – B = 1100100 same as converting 0 to 1 and 1 to 0 in B (taking 2’s complement of each bit in B) • So C = A + D + 1 - 1000000

  35. A “ten’s complement” scheme for decimal subtraction • A = 1234 a 4-digit decimal minuend • B = 0567 a 4-digit decimal subtrahend • Want to calculate the difference C = A – B • Rewrite C = A + (9999 – B ) +1 – 10000 • D = 9999 – B = 9432 (taking 10’s complement of each digit in B) • So C = A + D + 1 - 10000

  36. Binary Multiplication

  37. Exercises • 00011010 + 00001100 = ? • 00110011 - 00010110 = ? • 00101001 × 00000110 =?

  38. Summary • Decimal,Binary, and Hexadecimal Systems • Positional Numbering Systems • Conversions Between Number Systems • Conversions Between Power-of-Two Radices • Bits and Bytes • Basic Arithmetic Operations with Binary Numbers

  39. Resolution: Scanner and digital camera • Scanner and digital camera manufacturers often refer to two different types of resolution when listing product specs: optical resolution and interpolated (or digital) resolution. The optical resolution is the true measurement of resolution that the output device can capture. Interpolated, or digital, resolution is acquired artificially. • SPI (samples per inch) refers to scanning resolution.

  40. Summary- In this lecture, we have discussed: • Digitizing images • Pixels & resolution • Some common graphic file formats • Digital cameras & how to purchase one • Dynamic range, white balance, and color temperature • Graphic softwares

  41. High dynamic range imaging (HDRI) • The intention of HDRI is to accurately represent the wide range of intensity levels found in real scenes ranging from direct sunlight to the deepest shadows. • HDR images require a higher number of bits per color channel than traditional images, both because of the linear encoding and because they need to represent values from 10−4 to 108 (the range of visible luminance values) or more. 16-bit ("half precision") or 32-bit floating point numbers are often used to represent HDR pixels. • http://en.wikipedia.org/wiki/High_dynamic_range_imaging

More Related