0

I'm trying to figure out how to find 8's complement, but am unable to do so. Online it shows that we need to subtract each digit from 7 when the number is in it's octal bit. It gives the 7's complement and then we add 1 to it to gets the 8's complement.

However some other sources have been subtracting each digit of the number from 8 directly to get the 8's complement.

What is the right procedure of getting 8's complement?

  • I don't know, but in octal how would you do the second method if the number contained a 0? – Akiva Weinberger Dec 27 '22 at 20:19
  • @AkivaWeinberger the second method probably isn't done in octal, but I'm not sure what base is taken either. – crimsonKnight Dec 27 '22 at 20:22
  • Are you doing octal? Then, the first approach is right. –  Dec 27 '22 at 20:25
  • @StinkingBishop i see. Then even if the number isn't in octal I can convert it and then perform first method. Any idea whether the second method is credible or not and what base it works on? – crimsonKnight Dec 27 '22 at 20:42
  • 1
    The 7's and 8's complement only make sense in octal, it is not clear to me why you would do a conversion. If a base $n$ is given then you can apply $n-1$'s complement (subtract every digit from $n-1$) or $n$'s complement (same as $n-1$'s complement incremented by $1$). Note that you can have "8's complement" in base 9, which works differently from 8's complement in base 8, which is an unfortunate terminological ambiguity. (Thus, always specify your base first.) –  Dec 27 '22 at 20:50
  • 1
    (I was not very coherent in the previous comment, so to clarify: the first approach is how you calculate 8's complement in base 8. The second approach is how you calculate 8's complement in base 9. The same name "8's complement" is used for two different things, sadly.) –  Dec 27 '22 at 21:01
  • It's basically a matter of subtracting from $8^n-1$ versus subtracting from $8^n$ – Akiva Weinberger Dec 27 '22 at 21:22
  • @StinkingBishop hey thanks for clarifying! Now it makes all the more sense. – crimsonKnight Dec 28 '22 at 04:59

0 Answers0