Number Systems, Operations, and Codes Flashcards
Largest decimal number with n bits
With n bits, you can count up to a number equal to
(2raise to n) - 1.
Largest decimal number = (2 raise to n) - 1.
Represent fractional bits using binary
Fractional numbers can also be represented in binary by placing bits to the right of the
the binary point, just as fractional decimal digits are placed to the right of the binary point.
The left-most bit(after decimal) is the MSB in a binary fractional number and has a weight of 2^(-1) = 1/2 = 0.5[equivalent decimal weight]
The fractional weights decrease from left to right by a negative power of two for each bit.
Binary weight
All the bits to the left of the
binary point have weights that are positive powers of two, as previously discussed for whole
numbers. All bits to the right of the binary point have weights that are negative powers of
two, or fractional weights.
Binary-to-Decimal Conversion
Add the weights of all 1s in a binary number to get the decimal value.
Decimal whole number to binary:
Sum of weights:
determine the set of binary weights whose sum is equal to the decimal number
Decimal whole number to binary:
Repeated division by 2:
To get the binary number for a given decimal number, divide the decimal number by 2 until the quotient is 0. Remainders form the binary number. The first remainder to be produced is the LSB and last one is MSB.
Converting Decimal Fractions to Binary:
Sum-of-Weights
The sum-of-weights method can be applied to fractional decimal numbers, as shown:
0.625 = 0.5 + 0.125 = 2^-1 + 2^-3 = 0.101
There is a 1 in the 2^-1
position, a 0 in the 2^-2
position, and a 1 in the 2^-3
position.
Converting Decimal Fractions to Binary:
Repeated Multiplication by 2
to convert the decimal fraction 0.3125 to binary, begin by multiplying
0.3125 by 2 and then multiplying each resulting fractional part of the product by 2 until
the fractional product is 0 or until the desired number of decimal places is reached or stop when the fractional part is all zeros.
The carry digits, or carries, generated by the multiplications produce the binary number.
The first carry produced is the MSB, and the last carry is the LSB.
4 Basic rules of binary addition:
0 + 0 = 0 Sum of 0 with a carry of 0
0 + 1 = 1 Sum of 1 with a carry of 0
1 + 0 = 1 Sum of 1 with a carry of 0
1 + 1 = 10 Sum of 0 with a carry of 1
Binary addition, carry situation of adding 3 bits:
Carry bits
1 + 0 + 0 = 01 Sum of 1 with a carry of 0
1 + 1 + 0 = 10 Sum of 0 with a carry of 1
1 + 0 + 1 = 10 Sum of 0 with a carry of 1
1 + 1 + 1 = 11 Sum of 1 with a carry of 1
Binary Subtraction basic rules:
0 - 0 = 0
1 - 1 = 0
1 - 0 = 1
10 - 1 = 1 [0 - 1 with a borrow of 1]
Binary Multiplication, 4 basic rules:
0 * 0 = 0 0 * 1 = 0 1 * 0 = 0 1 * 1 = 1 Binary multiplication of two bits is the same as multiplication of the decimal digits 0 and 1.
Binary Division:
Division in binary follows the same procedure as division in decimal
1’s complement:
The 1’s complement of a binary number is found by changing all 1s to 0s and all 0s to 1s. here zero has two representations, 0000 0000 and 1111 1111.. not appreciated.
Logical circuit for 1’s complement:
Parallel inverters.
2’s complement
2’s complement = (1’s complement) + 1
OR the alternative method is:
Change all bits to the left of the least significant 1 to get 2’s complement.
for zero an overflow would occur but that taken care then main 8 bits represent 0.
Logical circuit for 2’s complement:
parallel inverters followed by an adder with a carry input [1].
Get true form (uncomplemented) from 1’s or 2’s complement:
Simply repeat what u did to get the complement.