Java Reference
In-Depth Information
In binary arithmetic the use of radix complements entails significant
computational advantages, principally because a binary machine can cal-
culatecomplementsveryrapidly.Forexample,thetwo'scomplementofa
binarynumberisobtainedinthesamemannerastheten'scomplementof
a decimal number, that is, by subtracting the number from an integer
power of the base that is larger than the number. In this manner the two's
complement of the binary number 101 is:
1000B = 2 3 = 8 decimal (higher power of 2)
- 101B =
5 decimal
----
---------
011B =
3 decimal
By the same token, the two's complement of 10110B is calculated
100000B = 2 5 = 32 decimal (higher power of 2)
- 10110B =
22 decimal
-------
----------
01010B
10 decimal
You can perform the binary subtraction of 11111B minus 10110B by
finding the two's complement of the subtrahend, adding the two
operands, and discarding any overflow digit, as follows:
11111B = 31 decimal
+ 01010B = 10 decimal (two's complement of 22)
-------
101001B
discard______|
01001B =
9 decimal (31 minus 22 = 9)
Diminished-radix integers
Inadditiontotheradixcomplements(ten'scomplementinthedecimalsys-
temandtwo'scomplementinthebinarysystem),thereisa diminishedra-
dix representation that is often useful. This encoding, sometimes called
the radix-minus-one form, is created by subtracting the number from an
integerpowerofthebaseminus1.Inthedecimalsystem,thediminishedra-
dixrepresentationiscalledthe nine'scomplement .Inthebinarysystemit
iscalledthe one'scomplement .Thenine'scomplementofthedecimalnum-
ber 76 is calculated as follows:
100 = next highest integer power of 10
99 = 100 minus 1
-
76
----
23 = nine's complement of 89
The one's complement of a binary number is obtained by subtracting
the number from an integer power of the base that is larger than the num-
Search WWH ::




Custom Search