Docsity

• Binary addition • Representing negative numbers, Exams of Number Theory

Partial preview of the text

Download • Binary addition • Representing negative numbers and more Exams Number Theory in PDF only on Docsity!

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Today

  • Binary addition• Representing negative numbers

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Binary Addition

Consider the following binary numbers:

How do we add these numbers?

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Binary Addition

And we have a carry now!

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Binary Addition

0 0 1And we have a carry again!

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Binary Addition

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Binary Addition

One more carry!

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Binary Addition

Behaves just like addition in decimal, but:• We carry to the next digit any time the sum

of the digits is 2 (decimal) or greater

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Negative Numbers

So far we have only talked about

representing non-negative integers

  • What can we add to our binary

representation that will allow this?

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Sign Magnitude Representation+

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Sign Magnitude Representation+

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Sign Magnitude RepresentationWhat is the problem with this approach?• Some of the arithmetic operators that we

have already developed do not do the rightthing

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Sign Magnitude RepresentationOperator problems:• For example, we have already designed a

counter (that implements an ‘increment’operation)

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Sign Magnitude RepresentationOperator problems:-

Increment

Andrew H. Fagg: Embedded Real-Time Systems: Binary Arithmetic

Sign Magnitude RepresentationOperator problems:-

Increment