Search code examples
numberscomputer-scienceoctal

finding values of x and y using Octal Base system


In finding the values of x and y, if (x567) + (2yx5) = (71yx) ( all in base 8) I proceeded as under.

I assumed x=abc and y=def and followed.

   (abc+010 def+101 110+abc 111+101)=(111 001 def abc) //adding ()+()=() and equating LHS=RHS.
    abc=111-010=101 which is 5 in base 8 and then def=001-101 which is -4
    so x=5 and y=-4 

Now the Question is that the answer mentioned in my book is x=4 and y=3.

Is the above method correct.If so,then what's issue here ??


Solution

  • you can't compare the digits beginning with the most significant digit, because you don't know the carry from the digit below. Also a digit cannot have a negative value.

    You can start with the least significant digit, because there is no carry:

    7 + 5 = 14
    

    so x = 4 with a carry of 1 at the next digit. now you can rewrite your equation to:

    (4567) + (2y45) = (71y4)
    

    now you can look at the second least significant digit (the carry in mind):

    6 + 4 + 1 (carry) = 13
    

    so y = 3, also with a carry of 1.

    the whole equation is:

    (4567) + (2345) = (7134)
    

    which is true for the octal system.