Number Theory Algorithms

Size: px
Start display at page:

Download "Number Theory Algorithms"

Transcription

1 Number Theory Algorithms Zeph Grunschlag Copyright Zeph Grunschlag, 2 22.

2 Agenda Euclidean Algorithm for GCD Number Systems Decimal numbers (base ) Binary numbers (base 2) One s complement Two s complement General base b number systems Arithmetic Algorithms Addition Multiplication Subtraction s and 2 s complement L 2

3 Euclidean Algorithm m, n Euclidean Algorithm gcd(m,n) integer euclid(pos. integer m, pos. integer n) = m, y = n while(y > ) r = mod y = y y = r return L 3

4 Euclidean Algorithm. Eample gcd(33,77): Step r = mod y y L 4

5 Euclidean Algorithm. Eample gcd(33,77): Step r = mod y y mod 77 = L 5

6 Euclidean Algorithm. Eample gcd(33,77): Step r = mod y y mod 77 = mod 33 = 33 L 6

7 Euclidean Algorithm. Eample gcd(33,77): Step r = mod y y mod 77 = mod 33 = 33 mod = L 7

8 Euclidean Algorithm. Eample gcd(244,7): Step r = mod y y L 8

9 Euclidean Algorithm. Eample gcd(244,7): Step r = mod y y mod 7 = 7 L 9

10 Euclidean Algorithm. Eample gcd(244,7): Step r = mod y y mod 7 = mod = 7 7 L

11 gcd(244,7): Euclidean Algorithm. Eample Step r = mod y y mod 7 = mod = mod 7 = L

12 gcd(244,7): Euclidean Algorithm. Eample Step r = mod y y mod 7 = mod = mod 7 = mod 3 = 3 L 2

13 gcd(244,7): Euclidean Algorithm. Eample Step r = mod y y mod 7 = mod = mod 7 = mod 3 = mod = By definition 244 and 7 are rel. prime. L 3

14 Euclidean Algorithm Correctness The reason that Euclidean algorithm works is gcd(,y ) is not changed from line to line. If, y denote the net values of, y then: gcd(,y ) = gcd(y, mod y) = gcd(y, qy) (the useful fact) = gcd(y, ) (subtract y multiple) = gcd(,y) L 4

15 Euclidean Algorithm Running Time EX: Compute the asymptotic running time of the Euclidean algorithm in terms of the number of mod operations: L 5

16 Euclidean Algorithm Running Time Assuming mod operation is O (): integer euclid(m, n) = m, y = n while( y > ) r = mod y = y y = r return O () +? ( O () + O () + O () + O () ) + O () =? O() Where? is the number of while loop iterations. L 6

17 Euclidean Algorithm Running Time Facts: ( = net value of, etc. ) 2. can only be less than y at very beginning of algorithm once > y, = y > y = mod y 4. When > y, two iterations of while loop guarantee that new is < ½ original because = y = mod y. Two cases: I. y > ½ mod y = y < ½ II. y ½ mod y < y ½ L 7

18 Euclidean Algorithm Running Time (&2) After first iteration, size of decreases by factor > 2 every two iterations. I.e. after 2m+ iterations, < original_ / 2 m Q: When in terms of m does this process terminate? L 8

19 Euclidean Algorithm Running Time After 2m+ steps, < original_ / 2 m A: While loop eits when y is, which is right before would have gotten =. Eiting while loop happens when 2 m > original_, so definitely by: m = log 2 ( original_ ) Therefore running time of algorithm is: O(2m+) = O(m) = O (log 2 (ma(a,b)) ) L 9

20 Euclidean Algorithm Running Time Measuring input size in terms of n = number of digits of ma(a,b): n = Θ(log (ma(a,b)) ) = Θ(log 2 (ma(a,b)) ) Therefore running time of algorithm is: O(log 2 (ma(a,b)) ) = O(n) (assumed naively that mod is an O() operation, so estimate only holds for fied size integers such as int s and long s) L 2

21 Number Systems Q: What does the string of symbols 234 really mean as a number and why? L 2

22 Number Systems A: 2 thousands hundreds 3 tens and 4 = But on the planet Ogg, the intelligent life forms have only one arm with 5 fingers. L 22

23 Number Systems So on Ogg, numbers are counted base 5. I.e. on Ogg 234 means: To distinguish between these systems, subscripts are used: (234) for Earth (234) 5 for Ogg L 23

24 Number Systems DEF: A base b number is a string of symbols u = a k a k a k 2 a 2 a a With the a i in {,,2,3,,b 2,b }. The string u represents the number (u ) b = a k b k + a k b k a b + a NOTE: When b >, run out of decimal number symbols so after 7, 8, 9 use capital letters, starting from A, B, C, L 24

25 Number Systems EG: base 2 (binary), base 8 (octal ) 74, 472 base 6 (headecimal ) 2F, ABCD Q: Compute the base version of these. L 25

26 Number Systems A: base 2 (binary), () 2 = = 5 () 2 = ( ) + 2 = 2 base 8 (octal ) 74, 472 (74) 8 = = 6 (472) 8 = = 34 base 6 (headecimal ) 2F, ABCD (2F) 6 = = 33 (ABCD) 6 = L 26

27 Number Systems Binary most natural system for bit strings and headecimal compactifies byte strings ( byte = 2 headecimals) EG in HTML: <font color="ffff"> Nice Color </font> Q: What color will this become? L 27

28 Number Systems A: "ffff" represents the rgb value: The first byte is for redness, the second byte is for green ness, and the last for blue ness. The HTML above specifies that = 255 redness and blueness values, but 6 + = green ness. Red and blue give purple, and 255 is the top brightness so this is bright purple. L 28

29 Number Systems Reverse Conversion Convert arbitrary decimal numbers into various bases, (calculator functions typically limited to base 2, 8, 6 and ). EG: Back at Ogg. Convert 646 to base 5. Try to do all operations base 5. L 29

30 Number Systems Reverse Conversion Back at Ogg. Convert 646 to base 5. Try to do all operations as an Oggian (base 5): (646) = (6) () 2 + (4) () + (6) Each quantity easy to convert into base 5: (6) =() 5 since 6 = 5 + (4) =(4) 5 since 4 < 5 () =(2) 5 since = So convert whole epression and do Oggian arithmetic: L 3

31 Number Systems Reverse Conversion Back at Ogg. Convert 646 to base 5. Try to do all operations as an Oggian (base 5): (646) = () 5 (2) (4) 5 (2) 5 + () 5 = L 3

32 Number Systems Reverse Conversion Back at Ogg. Convert 646 to base 5. Try to do all operations as an Oggian (base 5): (646) = () 5 (2) (4) 5 (2) 5 + () 5 = () 5 (4) 5 + (3) 5 + () 5 = L 32

33 Number Systems Reverse Conversion Back at Ogg. Convert 646 to base 5. Try to do all operations as an Oggian (base 5): (646) = () 5 (2) (4) 5 (2) 5 + () 5 = () 5 (4) 5 + (3) 5 + () 5 = (44) 5 + (4) 5 = L 33

34 Number Systems Reverse Conversion Back at Ogg. Convert 646 to base 5. Try to do all operations as an Oggian (base 5): (646) = () 5 (2) (4) 5 (2) 5 + () 5 = () 5 (4) 5 + (3) 5 + () 5 = (44) 5 + (4) 5 = (4) 5 Thinking like an Oggian hurts brain too much L 34

35 Number Systems Reverse Conversion Given an integer n and a base b find the string u such that (u ) b = n. Pseudocode: string represent(pos. integer n, pos. integer b) q = n, i = while( q > ) u i = q mod b q = q/b i = i + return u i u i u i 2 u 2 u u L 35

36 Number Systems Reverse Conversion EG: Convert 646 to Oggian (base 5): i u i = q mod b - q = q/b 646 L 36

37 Number Systems Reverse Conversion EG: Convert 646 to Oggian (base 5): i u i = q mod b mod 5 = q = q/b /5 =29 L 37

38 Number Systems Reverse Conversion EG: Convert 646 to Oggian (base 5): i u i = q mod b mod 5 = 29 mod 5 = 4 q = q/b /5 =29 29/5 =25 L 38

39 Number Systems Reverse Conversion EG: Convert 646 to Oggian (base 5): i u i = q mod b mod 5 = 29 mod 5 = mod 5 = q = q/b /5 =29 29/5 =25 25/5 =5 L 39

40 Number Systems Reverse Conversion EG: Convert 646 to Oggian (base 5): i u i = q mod b mod 5 = 29 mod 5 = mod 5 = 3 5 mod 5 = q = q/b /5 =29 29/5 =25 25/5 =5 5/5 = L 4

41 Number Systems Reverse Conversion EG: Convert 646 to Oggian (base 5): i 4 u i = q mod b mod 5 = 29 mod 5 = mod 5 = 3 5 mod 5 = mod 5 = Reading last column in reverse: 4 q = q/b /5 =29 29/5 =25 25/5 =5 5/5 = /5 = L 4

42 Number Systems In Class Eercise Some number theory facts are base dependent. For eample First Grade Teacher s Rule: A base number is divisible by 3 iff the sum of its digits are. Formally, let n = (u k u k u k 2 u 2 u u ). Then: n mod 3= u i mod 3 i= EG: because 3 ( = 2) k L 42

43 Arithmetical Algorithms Let s write down some familiar arithmetical algorithms. Conveniently, they run the same in any number base. In some cases, such as addition, there are asymptotically faster approaches, but these are the simplest procedures and tend to be fastest for relatively small (e.g. < bits) number sizes. L 43

44 Arithmetical Algorithms Addition Numbers are added from least significant digit to most, while carrying any overflow resulting from adding a column: base base 6 Carry: A 4 F + y C B 9 L 44

45 Arithmetical Algorithms Addition Numbers are added from least significant digit to most, while carrying any overflow resulting from adding a column: Carry: + y base base A 4 F C B 9 2 L 45 9

46 Arithmetical Algorithms Addition Numbers are added from least significant digit to most, while carrying any overflow resulting from adding a column: Carry: + y base base A 4 F C B L 46 F 9

47 Arithmetical Algorithms Addition Numbers are added from least significant digit to most, while carrying any overflow resulting from adding a column: Carry: + y base base A 4 F C B L 47 F F 9

48 Arithmetical Algorithms Addition Numbers are added from least significant digit to most, while carrying any overflow resulting from adding a column: Carry: + y A 4 F C B 9 base base L 48 6 F F 9

49 Arithmetical Algorithms Addition Numbers are added from least significant digit to most, while carrying any overflow resulting from adding a column: Carry: + y A 4 F C B 9 base base L 49 6 F F 9

50 Arithmetical Algorithms Addition of Positive Numbers string add(strings k k, y k y k y y, int base) carry =, k+ = y k+ = for(i = to k+) digitsum = carry + i + y i z i = digitsum mod base carry = digitsum /base return z k+ z k z k z z L 5

51 s Complement 2 s Complement The binary number system makes some operations especially simple and efficient under certain representations. Two such representations are s complement 2 s complement Each makes subtraction much simpler. Each has disadvantage that number length is predetermined. L 5

52 s Complement Fi k bits. (EG, k = 8 for bytes) Represent numbers with < 2 k Left most bit tells the sign positive (so positive no. s as usual) negative (but other bits change too!) Positive numbers the same as standard binary epansion Negative numbers gotten by taking the boolean complement, hence nomenclature L 52

53 s Complement Eamples k = 8: represents 8 represents 8 Notice: when add these representations as usual get, i.e. negative or =. Guess: adding numbers with mied sign works the same as adding positive numbers Trade off: not unique L 53

54 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 54

55 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 55

56 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 56

57 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 57

58 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 58

59 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 59

60 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 6

61 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 6

62 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 62

63 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 63

64 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 64

65 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 65

66 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 66

67 s Complement Addition Addition is the same as usual binary addition ecept: if the final carry is, cycle the carry to the least significant digit: represents 8, represents 2 Sum represents 6: Carry: +y pre sum overflow answer L 67

68 2 s Complement Fies the non uniqueness of zero problem Adding mied signs still easy No cycle overflow (pre computed) Java s approach (under the hood) Same fied length k, sign convention, and definition of positive numbers as with s complement Represent numbers with 2 (k ) < 2 (k ) EG. Java s byte ranges from 28 to +27 L 68

69 2 s Complement Negatives (slightly harder than s comp.): Compute s complement Add Summarize: = +. represents 8 + = represents 8. Add together without over flow: Q: What are the ranges of Java s 32 bit int and 64 bit long? (All of Java s integer types use 2 s complement) L 69

70 2 s Complement A: 2) 32 bit int s: Largest int =. = 2 3 = 2,47,483,647 Smallest int =. = 2 3 = 2,47,483,648 2) 64 bit long s: Largest long =. = 2 63 = 9,223,372,36,854,775,87 Smallest int =. = 2 63 = 9,223,372,36,854,775,88 L 7

71 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 7

72 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 72

73 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 73

74 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 74

75 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 75

76 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 76

77 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 77

78 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 78

79 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y L 79

80 2 s Complement Addition Addition is the same as usual binary addition no eceptions!! = ( 8), = ( 2) Sum together () = ( 3) : Carry: +y As a final check take the negative to see if get 3: ( +) = (+) =. YES! L 8

81 Arithmetical Algorithms Positive Binary Multiplication Long multiplication simplifies in binary because multiplying by 2 k amounts to left shifting k places (<<k), and each time multiply either by 2 k or 2 k. EG: y (<<) (<<) (<<2) (<<3) Add rows: L 8

82 Arithmetical Algorithms Positive Binary Multiplication Long multiplication simplifies in binary because multiplying by 2 k amounts to left shifting k places (<<k), and each time multiply either by 2 k or 2 k. EG: y (<<) (<<) (<<2) (<<3) Add rows: L 82

83 Arithmetical Algorithms Positive Binary Multiplication Long multiplication simplifies in binary because multiplying by 2 k amounts to left shifting k places (<<k), and each time multiply either by 2 k or 2 k. EG: y (<<) (<<) (<<2) (<<3) Add rows: L 83

84 Arithmetical Algorithms Positive Binary Multiplication Long multiplication simplifies in binary because multiplying by 2 k amounts to left shifting k places (<<k), and each time multiply either by 2 k or 2 k. EG: y (<<) (<<) (<<2) (<<3) Add rows: L 84

85 Arithmetical Algorithms Positive Binary Multiplication Long multiplication simplifies in binary because multiplying by 2 k amounts to left shifting k places (<<k), and each time multiply either by 2 k or 2 k. EG: y (<<) (<<) (<<2) (<<3) Add rows: L 85

86 Arithmetical Algorithms Positive Binary Multiplication Long multiplication simplifies in binary because multiplying by 2 k amounts to left shifting k places (<<k), and each time multiply either by 2 k or 2 k. EG: y (<<) (<<) (<<2) (<<3) Add rows: L 86

87 Arithmetical Algorithms Binary Multiplication bitstring multiply(bitstrings k k, y k y k y y ) = k k p = // the partial product for(i = to k+) if(y i == ) return p p = add(p, << i ) // prev. algorithm L 87

Binary Representations and Arithmetic

Binary Representations and Arithmetic Binary Representations and Arithmetic 9--26 Common number systems. Base : decimal Base 2: binary Base 6: hexadecimal (memory addresses) Base 8: octal (obsolete computer systems) Base 64 (email attachments,

More information

CS & IT Conversions. Magnitude 10,000 1,

CS & IT Conversions. Magnitude 10,000 1, CS & IT Conversions There are several number systems that you will use when working with computers. These include decimal, binary, octal, and hexadecimal. Knowing how to convert between these number systems

More information

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems SCHOOL OF ENGINEERING & BUILT ENVIRONMENT Mathematics Numbers & Number Systems Introduction Numbers and Their Properties Multiples and Factors The Division Algorithm Prime and Composite Numbers Prime Factors

More information

COMP Overview of Tutorial #2

COMP Overview of Tutorial #2 COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

More information

World Inside a Computer is Binary

World Inside a Computer is Binary C Programming 1 Representation of int data World Inside a Computer is Binary C Programming 2 Decimal Number System Basic symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Radix-10 positional number system. The radix

More information

Objectives. Connecting with Computer Science 2

Objectives. Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn how numbering systems are used to count Understand the significance of positional value

More information

in this web service Cambridge University Press

in this web service Cambridge University Press 978-0-51-85748- - Switching and Finite Automata Theory, Third Edition Part 1 Preliminaries 978-0-51-85748- - Switching and Finite Automata Theory, Third Edition CHAPTER 1 Number systems and codes This

More information

Introduction to Numbering Systems

Introduction to Numbering Systems NUMBER SYSTEM Introduction to Numbering Systems We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are Binary Base 2 Octal Base 8 Hexadecimal

More information

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Excerpt from Art of Problem Solving Volume 1: the Basics 2014 AoPS Inc. Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

More information

Number System. Introduction. Decimal Numbers

Number System. Introduction. Decimal Numbers Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

Arithmetic Processing

Arithmetic Processing CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

More information

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary

More information

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng Slide Set 1 for ENEL 339 Fall 2014 Lecture Section 02 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2014 ENEL 353 F14 Section

More information

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects: Numeral Systems -Numeral System -Positional systems -Decimal -Binary -Octal Subjects: Introduction A numeral system (or system of numeration) is a writing system for expressing numbers, that is a mathematical

More information

Chapter 2: Number Systems

Chapter 2: Number Systems Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

More information

add and subtract whole numbers with more than 4 digits, including using formal written methods (columnar addition and subtraction)

add and subtract whole numbers with more than 4 digits, including using formal written methods (columnar addition and subtraction) I created these worksheets because I think it is useful to have regular practice of calculation methods away from the point of teaching. There are worksheets. Questions are aligned to the Year curriculum,

More information

Representation of Non Negative Integers

Representation of Non Negative Integers Representation of Non Negative Integers In each of one s complement and two s complement arithmetic, no special steps are required to represent a non negative integer. All conversions to the complement

More information

Number representations

Number representations Number representations Number bases Three number bases are of interest: Binary, Octal and Hexadecimal. We look briefly at conversions among them and between each of them and decimal. Binary Base-two, or

More information

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related?

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related? Black Converting between Fractions and Decimals Unit Number Patterns and Fractions. Let n be a positive number. When we divide a decimal number, n, by 0, how are the numeral and the quotient related?.

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

More information

Hash Tables (Cont'd) Carlos Moreno uwaterloo.ca EIT https://ece.uwaterloo.ca/~cmoreno/ece250

Hash Tables (Cont'd) Carlos Moreno uwaterloo.ca EIT https://ece.uwaterloo.ca/~cmoreno/ece250 (Cont'd) Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 https://ece.uwaterloo.ca/~cmoreno/ece250 Last time we introduced the idea behind Hash Tables, and discussed hash functions and the issue of collisions.

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can

More information

6. Binary and Hexadecimal

6. Binary and Hexadecimal COMP1917 15s2 6. Binary and Hexadecimal 1 COMP1917: Computing 1 6. Binary and Hexadecimal Reading: Moffat, Section 13.2 Outline Number Systems Binary Computation Converting between Binary and Decimal Octal

More information

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 CS 64 Lecture 2 Data Representation Reading: FLD 1.2-1.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10?= 1010 2?= 1

More information

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,... Chapter 9 Computer Arithmetic Reading: Section 9.1 on pp. 290-296 Computer Representation of Data Groups of two-state devices are used to represent data in a computer. In general, we say the states are

More information

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence GATE Postal Correspondence Computer Sc. & IT 1 Digital Logic Computer Sciencee & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts,

More information

Binary Adders: Half Adders and Full Adders

Binary Adders: Half Adders and Full Adders Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order

More information

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR UNIT I Digital Systems: Binary Numbers, Octal, Hexa Decimal and other base numbers, Number base conversions, complements, signed binary numbers, Floating point number representation, binary codes, error

More information

TOPIC: NUMBER SYSTEMS

TOPIC: NUMBER SYSTEMS Ministry of Secondary Education Progressive Comprehensive High School PCHS Mankon Bamenda Department of Computer Studies Republic of Cameroon Peace Work - Fatherland TOPIC: NUMBER SYSTEMS Class: Comp.

More information

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation Complement Number Systems A complement number system is used to represent positive and negative integers A complement number system is based on a fixed length representation of numbers Pretend that integers

More information

BINARY SYSTEM. Binary system is used in digital systems because it is:

BINARY SYSTEM. Binary system is used in digital systems because it is: CHAPTER 2 CHAPTER CONTENTS 2.1 Binary System 2.2 Binary Arithmetic Operation 2.3 Signed & Unsigned Numbers 2.4 Arithmetic Operations of Signed Numbers 2.5 Hexadecimal Number System 2.6 Octal Number System

More information

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

More information

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr Number Systems and Binary Arithmetic Quantitative Analysis II Professor Bob Orr Introduction to Numbering Systems We are all familiar with the decimal number system (Base 10). Some other number systems

More information

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29 CS 31: Introduction to Computer Systems 03: Binary Arithmetic January 29 WiCS! Swarthmore Women in Computer Science Slide 2 Today Binary Arithmetic Unsigned addition Subtraction Representation Signed magnitude

More information

Number Systems CHAPTER Positional Number Systems

Number Systems CHAPTER Positional Number Systems CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

More information

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.

More information

Euclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm

Euclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm MA/CSSE 473 Day 06 Euclid's Algorithm MA/CSSE 473 Day 06 Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm 1 Quick look at review topics in textbook REVIEW

More information

Divisibility Rules and Their Explanations

Divisibility Rules and Their Explanations Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although

More information

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value 1 Number System Introduction In this chapter, we will study about the number system and number line. We will also learn about the four fundamental operations on whole numbers and their properties. Natural

More information

Data Representation 1

Data Representation 1 1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

More information

N.B. These pastpapers may rely on the knowledge gained from the previous chapters.

N.B. These pastpapers may rely on the knowledge gained from the previous chapters. N.B. These pastpapers may rely on the knowledge gained from the previous chapters. 1 SEC 95-PAPER 1-Q5 (a) A computer uses 8-bit two s complement numbers. In the space below fill in the largest positive

More information

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization. Data Representation COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

More information

Internal Data Representation

Internal Data Representation Appendices This part consists of seven appendices, which provide a wealth of reference material. Appendix A primarily discusses the number systems and their internal representation. Appendix B gives information

More information

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10)

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10) Kindergarten 1 Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality,, Number and Operations in Base 10) Kindergarten Counting and Cardinality Know number names and the count sequence.

More information

MAT 243 Test 2 SOLUTIONS, FORM A

MAT 243 Test 2 SOLUTIONS, FORM A MAT 243 Test 2 SOLUTIONS, FORM A 1. [15 points] Calculate the following quantities: a. 17 mod 4 Solution: 17 17 4 = 17 4 4 = 1. 4 b. 17 div 4 17 Solution: = 4. 4 c. (( 1) mod 12) mod (27 div 5) Solution:

More information

Chapter 5: Computer Arithmetic. In this chapter you will learn about:

Chapter 5: Computer Arithmetic. In this chapter you will learn about: Slide 1/29 Learning Objectives In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations using binary numbers Addition (+) Subtraction (-) Multiplication

More information

Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems

Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems In everyday life, we humans most often count using decimal or base-10 numbers. In computer science, it

More information

Number Systems (2.1.1)

Number Systems (2.1.1) Number Systems (2.1.1) Concept of a register. Operations of register, Complementation, Ranges, Left and right shifts, Addition of two binary number, Numerical overflow, 2 s complement representation, Binary

More information

THE LOGIC OF COMPOUND STATEMENTS

THE LOGIC OF COMPOUND STATEMENTS CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS Copyright Cengage Learning. All rights reserved. SECTION 2.5 Application: Number Systems and Circuits for Addition Copyright Cengage Learning. All rights reserved.

More information

Arithmetic Operations

Arithmetic Operations Arithmetic Operations Arithmetic Operations addition subtraction multiplication division Each of these operations on the integer representations: unsigned two's complement 1 Addition One bit of binary

More information

When using computers, it should have a minimum number of easily identifiable states.

When using computers, it should have a minimum number of easily identifiable states. EET 3 Chapter Number Systems (B) /5/4 PAGE Number Systems (B) Number System Characteristics (Tinder) What s important in choosing a number system? Basically, there are four important characteristics desirable

More information

Unit 7 Number System and Bases. 7.1 Number System. 7.2 Binary Numbers. 7.3 Adding and Subtracting Binary Numbers. 7.4 Multiplying Binary Numbers

Unit 7 Number System and Bases. 7.1 Number System. 7.2 Binary Numbers. 7.3 Adding and Subtracting Binary Numbers. 7.4 Multiplying Binary Numbers Contents STRAND B: Number Theory Unit 7 Number System and Bases Student Text Contents Section 7. Number System 7.2 Binary Numbers 7.3 Adding and Subtracting Binary Numbers 7.4 Multiplying Binary Numbers

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017 4/8/17 Admin! Assignment 5 BINARY David Kauchak CS 52 Spring 2017 Diving into your computer Normal computer user 1 After intro CS After 5 weeks of cs52 What now One last note on CS52 memory address binary

More information

Learning Objectives. Binary over Decimal. In this chapter you will learn about:

Learning Objectives. Binary over Decimal. In this chapter you will learn about: Ref Page Slide 1/29 Learning Objectives In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations using binary numbers Addition (+) Subtraction

More information

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up

More information

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc. Chapter 3: Number Systems and Codes Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc., 5 th edition Decimal System The radix or base of a number system determines

More information

The type of all data used in a C++ program must be specified

The type of all data used in a C++ program must be specified The type of all data used in a C++ program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values There are

More information

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS Chapter 1. 1.1. INTRODUCTION Digital computers have brought about the information age that we live in today. Computers are important tools because they can locate and process enormous amounts of information

More information

MATH 104B OCTAL, BINARY, AND HEXADECIMALS NUMBERS

MATH 104B OCTAL, BINARY, AND HEXADECIMALS NUMBERS MATH 104B OCTAL, BINARY, AND HEXADECIMALS NUMBERS A: Review: Decimal or Base Ten Numbers When we see a number like 2,578 we know the 2 counts for more than the 7, even though 7 is a larger number than

More information

Signed umbers. Sign/Magnitude otation

Signed umbers. Sign/Magnitude otation Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

More information

Module 1: Information Representation I -- Number Systems

Module 1: Information Representation I -- Number Systems Unit 1: Computer Systems, pages 1 of 7 - Department of Computer and Mathematical Sciences CS 1305 Intro to Computer Technology 1 Module 1: Information Representation I -- Number Systems Objectives: Learn

More information

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING, THE UNIVERSITY OF NEW MEXICO ECE-238L: Computer Logic Design Fall 2013.

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING, THE UNIVERSITY OF NEW MEXICO ECE-238L: Computer Logic Design Fall 2013. ECE-8L: Computer Logic Design Fall Notes - Chapter BINARY NUMBER CONVERSIONS DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-b-digit representation of a positive integer number (powers

More information

For more information, see the Math Notes box in Lesson of the Core Connections, Course 1 text.

For more information, see the Math Notes box in Lesson of the Core Connections, Course 1 text. Number TYPES OF NUMBERS When two or more integers are multiplied together, each number is a factor of the product. Nonnegative integers that have eactly two factors, namely, one and itself, are called

More information

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer.

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Computer Arithmetic In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Numbers have a long history. In Europe up to about 400 numbers were

More information

DIGITAL SYSTEM DESIGN

DIGITAL SYSTEM DESIGN DIGITAL SYSTEM DESIGN UNIT I: Introduction to Number Systems and Boolean Algebra Digital and Analog Basic Concepts, Some history of Digital Systems-Introduction to number systems, Binary numbers, Number

More information

Number Systems. Both numbers are positive

Number Systems. Both numbers are positive Number Systems Range of Numbers and Overflow When arithmetic operation such as Addition, Subtraction, Multiplication and Division are performed on numbers the results generated may exceed the range of

More information

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System For Your Amusement Number Systems and Number Representation Jennifer Rexford Question: Why do computer programmers confuse Christmas and Halloween? Answer: Because 25 Dec = 31 Oct -- http://www.electronicsweekly.com

More information

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those? 9/10/18 1 Binary and Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those? Hexadecimal Numbers Check Homework 3 Binary Numbers A binary (base-two) number

More information

Digital Fundamentals

Digital Fundamentals Digital Fundamentals Tenth Edition Floyd Chapter 2 2009 Pearson Education, Upper 2008 Pearson Saddle River, Education NJ 07458. All Rights Reserved Decimal Numbers The position of each digit in a weighted

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

Level ISA3: Information Representation

Level ISA3: Information Representation Level ISA3: Information Representation 1 Information as electrical current At the lowest level, each storage unit in a computer s memory is equipped to contain either a high or low voltage signal Each

More information

The Design of C: A Rational Reconstruction"

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah NUMBER OPERATIONS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah CS/ECE 3810: Computer Organization Overview Homework 4 is due tonight Verify your uploaded file before the

More information

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 APPENDIX A.1 Number systems and codes Since ten-fingered humans are addicted to the decimal system, and since computers

More information

Lecture 3.4: Recursive Algorithms

Lecture 3.4: Recursive Algorithms Lecture 3.4: Recursive Algorithms CS 250, Discrete Structures, Fall 2014 Nitesh Saxena Adopted from previous lectures by Zeph Grunschlag Course Admin Graded Mid-Term 1 Please pick them up, if you haven

More information

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC 1 2 Semester Transition Point EE 109 Unit 11 Binary Arithmetic At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is

More information

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators CSE 351: The Hardware/Software Interface Section 2 Integer representations, two s complement, and bitwise operators Integer representations In addition to decimal notation, it s important to be able to

More information

Decimal Binary Conversion Decimal Binary Place Value = 13 (Base 10) becomes = 1101 (Base 2).

Decimal Binary Conversion Decimal Binary Place Value = 13 (Base 10) becomes = 1101 (Base 2). DOMAIN I. NUMBER CONCEPTS Competency 00 The teacher understands the structure of number systems, the development of a sense of quantity, and the relationship between quantity and symbolic representations.

More information

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8 Data Representation At its most basic level, all digital information must reduce to 0s and 1s, which can be discussed as binary, octal, or hex data. There s no practical limit on how it can be interpreted

More information

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0 Integers So far, we've seen how to convert numbers between bases. How do we represent particular kinds of data in a certain (32-bit) architecture? We will consider integers floating point characters What

More information

CS 64 Week 1 Lecture 1. Kyle Dewey

CS 64 Week 1 Lecture 1. Kyle Dewey CS 64 Week 1 Lecture 1 Kyle Dewey Overview Bitwise operation wrap-up Two s complement Addition Subtraction Multiplication (if time) Bitwise Operation Wrap-up Shift Left Move all the bits N positions to

More information

Binary Representation. Jerry Cain CS 106AJ October 29, 2018 slides courtesy of Eric Roberts

Binary Representation. Jerry Cain CS 106AJ October 29, 2018 slides courtesy of Eric Roberts Binary Representation Jerry Cain CS 106AJ October 29, 2018 slides courtesy of Eric Roberts Once upon a time... Claude Shannon Claude Shannon was one of the pioneers who shaped computer science in its early

More information

COMPETENCY 1.0 UNDERSTAND THE STRUCTURE OF THE BASE TEN NUMERATION SYSTEM AND NUMBER THEORY

COMPETENCY 1.0 UNDERSTAND THE STRUCTURE OF THE BASE TEN NUMERATION SYSTEM AND NUMBER THEORY SUBAREA I. NUMBERS AND OPERATIONS COMPETENCY.0 UNDERSTAND THE STRUCTURE OF THE BASE TEN NUMERATION SYSTEM AND NUMBER THEORY Skill. Analyze the structure of the base ten number system (e.g., decimal and

More information

Section A Arithmetic ( 5) Exercise A

Section A Arithmetic ( 5) Exercise A Section A Arithmetic In the non-calculator section of the examination there might be times when you need to work with quite awkward numbers quickly and accurately. In particular you must be very familiar

More information

Chapter 5: Computer Arithmetic

Chapter 5: Computer Arithmetic Slide 1/29 Learning Objectives Computer Fundamentals: Pradeep K. Sinha & Priti Sinha In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations

More information

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation Princeton University Computer Science 27: Introduction to Programming Systems Goals of this Lecture and Number Representation Help you learn (or refresh your memory) about: The binary, hexadecimal, and

More information

Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

Lecture 8: Addition, Multiplication & Division

Lecture 8: Addition, Multiplication & Division Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C

More information

Chapter 4 Arithmetic Functions

Chapter 4 Arithmetic Functions Logic and Computer Design Fundamentals Chapter 4 Arithmetic Functions Charles Kime & Thomas Kaminski 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Overview Iterative combinational

More information

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude Chapter 2 Positional number systems A positional number system represents numeric values as sequences of one or more digits. Each digit in the representation is weighted according to its position in the

More information

Bits, Words, and Integers

Bits, Words, and Integers Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

More information

Lecture 5: Arithmetic and Algebra Steven Skiena. skiena

Lecture 5: Arithmetic and Algebra Steven Skiena.  skiena Lecture 5: Arithmetic and Algebra Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena How Long is Long? Today s PCs are

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

FUNDAMENTAL ARITHMETIC

FUNDAMENTAL ARITHMETIC FUNDAMENTAL ARITHMETIC Prime Numbers Prime numbers are any whole numbers greater than that can only be divided by and itself. Below is the list of all prime numbers between and 00: Prime Factorization

More information

Lecture 1: What is a computer?

Lecture 1: What is a computer? 02-201, Fall 2015, Carl Kingsford Lecture 1: What is a computer? 0. Today's Topics Basic computer architecture How the computer represents data 1. What is a computer? A modern computer is a collection

More information

Number Systems and Their Representations

Number Systems and Their Representations Number Representations Cptr280 Dr Curtis Nelson Number Systems and Their Representations In this presentation you will learn about: Representation of numbers in computers; Signed vs. unsigned numbers;

More information

Chapter 2 Exercises and Answers

Chapter 2 Exercises and Answers Chapter 2 Exercises and nswers nswers are in blue. For Exercises -5, match the following numbers with their definition.. Number. Natural number C. Integer number D. Negative number E. Rational number unit

More information