Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Binary Number Representations: BCD, Signed Numbers, and Arithmetic Operations, Study notes of Number Theory

Various ways of representing binary numbers, including Binary Coded Decimal (BCD), sign-magnitude, offset binary (Excess-K), 1's complement, and 2's complement. It also covers arithmetic operations using these representations.

Typology: Study notes

2021/2022

Uploaded on 09/27/2022

obesix
obesix 🇺🇸

4.2

(18)

239 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
2.4. BCD 17
2.4 BCD
Binary Coded Decimal is just what it says it is. Here the decimal digits 0 - 9 are coded into
binary. For each digit we need 4 bits. 0000, 0001, . . . , 1001. The remaining 4-bit numbers
are not used.
13710 = 0001 0011 0111 (BCD)
This is not the same as Binary! looks like binary but...
BCD provides ease of interfacing for digital displays e.g. 7 segment displays.
BCD is wasteful of bits.
The conversion between BCD and binary is complicated. Thus most arithmetic operations
are done with binary rather than other representations. (However it is possible to implement
arithmetic in BCD but with a carry between the columns).
2.5 Signed numbers
Sooner or later it becomes necessary to represent negative numbers. Can’t perform arithmetic
easily without signed numbers.
2.5.1 Sign-magnitude representation
Perhaps the simplest way to represent a negative number is to devote the MSB to indicating
the sign.
Sign-magnitude is often used where numbers are to be displayed (The MSB is simply tied to
the sign display).
Sign-magnitude is also used in some A/D conversion schemes.
However sign-magnitude is not the best for carrying out computation.
pf3
pf4
pf5

Partial preview of the text

Download Binary Number Representations: BCD, Signed Numbers, and Arithmetic Operations and more Study notes Number Theory in PDF only on Docsity!

2.4. BCD 17

2. 4 BCD

  • Binary Coded Decimal is just what it says it is. Here the decimal digits 0 - 9 are coded into binary. For each digit we need 4 bits. 0000, 0001,... , 1001. The remaining 4-bit numbers are not used. 13710 = 0001 0011 0111 (BCD)
  • This is not the same as Binary! looks like binary but...
  • BCD provides ease of interfacing for digital displays e.g. 7 segment displays.
  • BCD is wasteful of bits.
  • The conversion between BCD and binary is complicated. Thus most arithmetic operations are done with binary rather than other representations. (However it is possible to implement arithmetic in BCD but with a carry between the columns).

2. 5 Signed numbers

  • Sooner or later it becomes necessary to represent negative numbers. Can’t perform arithmetic easily without signed numbers.

2.5. 1 Sign-magnitude representation

  • Perhaps the simplest way to represent a negative number is to devote the MSB to indicating the sign.
  • Sign-magnitude is often used where numbers are to be displayed (The MSB is simply tied to the sign display).
  • Sign-magnitude is also used in some A/D conversion schemes.
  • However sign-magnitude is not the best for carrying out computation.

18 CHAPTER 2. DATA REPRESENTATION

2.5. 2 Offset Binary representation (Excess-K)

  • Offset Binary is where one subtracts K (usually half the largest possible number) from the representation to get the value.
  • Has the advantage that the number sequence from the most negative to the most positive is a simple binary progression, which makes it a natural for binary counters.
  • note that the MSB still carries the sign information.
  • Excess K is used in conjunction with floating point representations for the exponent. We will meet this again shortly.
  • A note on arithmetic in Excess K: Assume a, b, c are three values: (a + b) = c (values) (a + k) + (b + k) (representations) = (a + b) + 2 k = (c + k) + k Rewriting A, B, C in Excess-K representations: A + B = C + k C = (A + B) − k
  • Try this for (-1) + (+1) = 0

2.5. 3 2 ’s complement

  • 2’s complement represents the method most widely used for integer computation.
  • Positive numbers are represented in simple unsigned binary.
  • The system is rigged so that a negative number is represented as the binary number that when added to a positive number of the same magnitude gives zero.
  • To get the two’s complement, first take the ones complement, then add one.

2.5. 4 1 ’s complement

  • Exchange all the 1’s for 0’s and vice versa.

20 CHAPTER 2. DATA REPRESENTATION

Example 2.6. 3 (subtraction from a negative) 1100 (-3) +1101 (-2) (1) 1001 (-6?) The solution is to wrap the carry back in to the LSB. Exercise 2.6. 4 Can you explain why this works?

2.6. 2 In 2 ’s complement

The Arithmetic operations are perhaps easiest in 2’s complement.

  • To add... just like in any other base. Example 2.6. 5 (addition 5 + (-2):) 0101 (+5) +1110 (-2) 0011 (+3)
  • To subtract B from A take the 2’s complement of B and add to A. Example 2.6. 6 (subtraction 2 - 5:) 0010 (+2) (2 + (-5)) +1011 (-5) since +5 = 0101 : 1101 (-3)

2.6. PERFORMING ARITHMETIC 21

value Sign Offset 2’s Magnitude Binary complement +7 0111 1111 0111 +6 0110 1110 0110 +5 0101 1101 0101 +4 0100 1100 0100 +3 0011 1011 0011 +2 0010 1010 0010 +1 0001 1001 0001 0 0000 1000 0000 -1 1001 0111 1111 -2 1010 0110 1110 -3 1011 0101 1101 -4 1100 0100 1100 -5 1101 0011 1011 -6 1110 0010 1010 -7 1111 0001 1001 -8 - 0000 1000 -0 1000 - -

  • Multiplication also works right in 2’s complement. Long multiplication reduces to shifts and adds
  • We have implicitly used the concept of carry. In particular we dropped/ignored the carry bit in the case of the two’s complement number representation. Example 2.6. 7 (3 – 3 =) 0011 ( 3) +1101 (–3) (1) 0000 (0) (c.f. above 1’s complement example)