Basic Theory
Read more »
Subtraction can be regarded as addition. For example A - B is same as A + (-B). In binary most computer uses 2’s complement form to represent negative binary number. The subtrahend is first converted to 2’s complement form to make it negative and then is added to minued. This is same as above example.
Code Assumption
This code is capable to perform subtraction between two decimal numbers from 0 to 127. The subtrahend is first converted into 2’s complement form and then addition is perform. After addition the result is obtained. If the result has 1 in its MSB then it is treated as negative result and is converted to decimal format otherwise it is treated as positive number and converted to positive decimal.
Source Code:
تعليقات: 0
إرسال تعليق