Java Reference
In-Depth Information
Radix-complement integers
Arithmetic complements arise during subtraction. In general, the radix
complementofanumberisdefinedasthedifferencebetweenthenumber
andthenextintegerpowerofthebasethatislargerthanthenumber.Indec-
imalnumberstheradixcomplementiscalledthe ten'scomplement .Inthe
binarysystemtheradixcomplementisthe two'scomplement .Forexample,
theradixcomplementofthedecimalnumber89(ten'scomplement),iscal-
culated as follows:
100 = higher power of 10
-
89
----
11 = ten's complement of 89
The use of radix complements to simplify machine subtraction can
best be seen in an example. Suppose the operation to be performed is x =
a - b with the following values:
a = 602
b = 353
602
- 353
-----
x =
249
Notice that in the process of performing longhand subtraction you had
to perform two borrow operations. Now consider that the radix comple-
ment (ten's complement) of 353 is
1000 - 353 = 647
Using complements, we can reformulate subtraction as the addition of
the ten's complement of the subtrahend, as follows
602
+ 647
-----
1249
|____________ discarded digit
The result is adjusted by discarding the digit that overflows the magni-
tude of the operands.
In longhand decimal arithmetic there is no advantage in replacing sub-
traction with ten's complement addition, since the additional labor re-
quired for calculating the ten's complement cancels out any other
possible benefit.
Search WWH ::




Custom Search