Presentation on theme: "Lecture 2 Number Systems"— Presentation transcript:
1 Lecture 2 Number Systems Introduction to Information TechnologyLecture 2 Number SystemsDr. Ken Tsang 曾镜涛Room E408 R9
2 Get slides from:The glossary and PDF version of the slides are here:
3 Outline Decimal Number System Binary Number System Hexadecimal Number SystemPositional Numbering SystemConversions Between Number SystemsConversions Between Power-of-Two RadicesBits, Bytes, and WordsBasic Arithmetic Operations with Binary Numbers
4 Natural NumbersNatural numbersZero and any number obtained by repeatedly adding one to itNegative NumbersA value less than 0, with a – signIntegersA natural number, a negative number, zeroRational NumbersAn integer or the quotient of two integersWe will only discuss the binary representation of non-negative integers
5 Decimal Number SystemA human usually has four fingers and a thumb on each hand, giving a total of ten digits over both hands10 digits:0,1,2,3,4,5,6,7,8,9Also called base-10 number system,Or Hindu-Arabic, or Arabic systemCounting in base-101,2,…,9,10,11,…,19,20,21,…,99,100,…Decimal number in expanded notation234 = 2 * * * 1
6 Binary Number System Binary number system has only two digits 0, 1Also called base-2 systemCounting in binary system0, 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* *4 + 1*2 + 1*1 = (11)10
7 Gottfried Leibniz ( )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 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 digitsZero: represented by a broken lineOne: 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,FAlso called base-16 systemCounting in Hexadecimal0,1,…,F,10,11,…,1F,20,…FF,100,…Hexadecimal number in expanded notation(FF)16 = 15* *160 = (255)10
12 Positional Numbering System The value of a digit in a number depends on:The digit itselfThe position of the digit within the numberSo 123 is different from 321123: 1 hundred, 2 tens, and 3 units321: 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 rr is called the base, or radix
14 The Octal System (base 8) Valid symbols: 0,1,2,3,4,5,6,7= ?Questions:2. How to count in Octal?
15 Why Binary? A computer is a Binary machine It knows only ones and zeroesEasy to implement in electronic circuitsReliableCheap
16 Bit and Byte BIT = Binary digIT, “0” or “1” State of on or off ( high or low) of a computer circuitKilo 1K = 210 = 1024 ≈ 103Mega 1M = 220 = 1,048,576 ≈ 106Giga 1G = 230 = 1,073,741,824 ≈ 109
17 Bit and Byte Byte is the basic unit of addressable memory 1 Byte = 8 BitsThe right-most bit is called the LSBLeast Significant BitThe Left-most bit is called the MSBMost Significant Bit
18 Why Hexadecimal?Hexadecimal is meaningful to humans, and easy to work with for a computerCompactA BYTE is composed of 8 bitsOne byte can thus be expressed by 2 digits in hexadecimal EFb EFhSimple 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 = (?)10What’s wrong?(187)8 = 1*64 + 8*8 + 7*1
22 Conversions Between Number Systems Decimal to Binary32110 = ?2remainderquotient321 / 2 =1601160 / 2 =8080 / 2 =4040 / 2 =2020 / 2 =1010 / 2 =55 / =22 / =1 / =Reading the remainders from bottom to top, we have32110 =
24 Conversions Between Number Systems Decimal to Base rSame as Decimal to BinaryDivide the number by rRecord the quotient and remainderDivide the new quotient by r again…..Repeat until the newest quotient is 0Read the remainder from bottom to top
25 Exercises Convert 19910 to binary Convert 25510 to binary Please show your steps of conversion clearly.Convert to binaryConvert to binaryConvert to hexadecimalConvert 2558 to decimalConvert to decimal
26 Conversions Between Power-of-2 Radices Because 16 = 24, a group of 4 bits is easily recognized as a Hexadecimal digitAnd a group of 3 bits is easily recognized as one Octal digitTo convert a Hex or Octal number to a binary numberRepresent 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 Addition1+1=0, with one to carry to the next place
33 Two’s Complement Alternative way of doing Binary Subtraction Invert the digits (of the subtrahend)Add 1Add this to the minuend=Drop/Ignore the MSB
34 Why “Two’s Complement” works? Suppose A = a 7-bit binary minuendB = a 7-bit binary subtrahendWant to calculate the difference C = A – BRewrite C = A + ( – B ) +1 –D = – B = 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
35 A “ten’s complement” scheme for decimal subtraction A = 1234 a 4-digit decimal minuendB = 0567 a 4-digit decimal subtrahendWant to calculate the difference C = A – BRewrite C = A + (9999 – B ) +1 – 10000D = 9999 – B = 9432 (taking 10’s complement of each digit in B)So C = A + D
38 Summary Decimal, Binary, and Hexadecimal Systems Positional Numbering SystemsConversions Between Number SystemsConversions Between Power-of-Two RadicesBits and BytesBasic 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 imagesPixels & resolutionSome common graphic file formatsDigital cameras & how to purchase oneDynamic range, white balance, and color temperatureGraphic 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.