Binary representations

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

How are numbers represented in Two's complement?

Like One's complement, for negative numbers, all bits are flipped, but then also a 1 is added to it. Benefits: represents 0 only once (but does have an extra negative number so is asymmetric) Major benefit is that A-Y = X+(-Y), thus there is no need for a separate sub-tractor like in Sign and Magnitude or to carry-out adjustments like with One's complement.

Choose a random number in decimal, convert it to binary.

Method: divide the number by 2 giving the quotient and remainder. Repeat the division process with the quotient each time listing the remainder until the quotient is zero. The answer is obtained by reading the remainder column bottom to top.

Write a binary sequence, convert it to decimal.

Method: going along from right to left the string of binary. The first is worth (0or1)*2^0, the next worth (0or1)*2^1, the next (0or1)*2^2, and so on. Sum the result of these and the answer is your decimal number.

What properties do we desire in a good representation of signed integers?

1. Only one bit pattern per value. 2. Have an equal number of positive and negative values. 3. No gaps in the range of values. 4. An economic hardware implementation.

List the possible representations of signed integers.

1. Sign and Magnitude 2. One's complement 3. Two's complement 4. Excess-n 5. Binary Coded Decimal (BCD)

How are numbers represented in One's Complement?

Negative numbers are the complement (all 0's and 1's are flipped to their opposites) of their positive counterpart. Problems: 0 is represented twice.

Choose some binary or octal number, convert it to the other format.

One octal digit (0-7) corresponds to three binary digits. So if converting from octal - simply express each octal number in three binary digits. If converting binary, break it into groups of three starting on the right, and their summed value is the octal value.

Choose some binary or hexadecimal string, now convert it to the other format.

Since 16 = 2^4 each hexadecimal digit can be represented by four binary digits. Thus do what you would do for octal but with hexadecimal - i.e. with 4 binary numbers rather than 3. Recall hexadecimal goes 0-9,A-F.

How are numbers represented in Sign & Magnitude?

The leftmost bit represents the sign, the rest the number. Problems: represent 0 twice, costly to implement.

How are numbers represented in Excess-n?

A bitstring with n 0's maps to the smallest value and the bitstring with n1's maps to the largest value. So for example if we have 4-bits then we can represent 2^4=16 values in total. So including signed terms: 0000 = -8 and 1111 = 7.

How are characters represented in binary?

Characters are mapped to bit patters, common mappings are ASCII and Unicode. ASCII uses 7 bits (giving it 128 bit patterns).


Ensembles d'études connexes

Diuretic/ Fluid and Electrolyte Practice Questions- Pharmacology I

View Set

Project Management Cumulative Final

View Set

Unit 20. Vocab. F. Match to make sentences.

View Set

Managerial Chapter AC 210 Exam 3

View Set

Chapter 10: Terminating Relationships

View Set

World History Chapter 18 : The French Revolution and Napoleon

View Set