0

Well the question is that I have to perform an octal subtraction using 8's complement method. The question is like this: (611.21)base 8 - (304.42)base 8. Subtraction part is fine but the problem comes when taking the 8's complement of the number. After you calculate the 7's complement i.e. (473.35)base 8, we add 1 to make it 8's complement. My doubt is that 1 is simply to be added or 1 is to be added to the rightmost digit.

Because according to the method by GeeksForGeeks,

To find b’s complement, just add 1 to the calculated (b-1)’s complement.

By doing so, the answer to my answer of subtraction is coming (474.35)base 8 , but if you do the subtraction in the normal way (without 8's complement method), the answer comes out to be (304.57)base 8.

I have looked for the solution at so many places but I am still in a dilemma of what's the correct one.

To summarise my points, I would like to ask that when finding 8's complement of a fractional octal value, we simply add 1 to the 7's complement or do we add 1 to the rightmost bit of the answer.

Utkarsh Sahu
  • 409
  • 3
  • 16

1 Answers1

0

Let N be a number in base b, having an integer part of n digits and fractional part of m digits. When you take a b's complement, you are essentially subtracting that number from b^n i.e. b^n - N. This is intuitive even when you have a fractional part in N.

Things become slightly different when you have to deal with (b-1)'s complement. The case is fairly simple when you have to deal with integers. You just subtract the number from b^n - 1. So if you want the 9's complement of 8 it would be 9 - 8 = 1 or if you want 10's complement it is 10 - 8 = 9 - 8 + 1 = 2, and this is what you claim, To find b’s complement, just add 1 to the calculated (b-1)’s complement. This however holds only when the numbers don't have a fractional part. We extend the idea of subtracting 1 to go from base b complement to base b-1 complement to the fractional part, so if you want the 9's complement of 8.1 you have to subtract 8.1 from 9.9 and not just 9. Generalizing this idea, (b-1)'s complement is defined to be (b^n - b^-m) - N. From here you can easily find out that for integers, b's complement - (b-1)'s complement = b^n - N - ((b^n - b^-0) - N) = b^0 = 1.

TLDR;

When finding 8's complement of a fractional octal value, we simply add 1 to the 7's complement or do we add 1 to the rightmost bit of the answer, both of them mean the same as long as you only have to deal with integers. With fractions, you add it to the rightmost bit of the fractional part. This can be proved in a similar way as above.

Rinkesh P
  • 588
  • 4
  • 13