1

For some backstory, I'm making a program that can do arithmetic on ones complement numbers. To do this I'm converting a binary string into a BigInteger and then performing the math using said BigIntegers, and then converting that back into a binary string. The only problem occurs when the end result goes below -127 or above +127 because I don't know how to correct it due to the nature of ones complement numbers. I was hoping I could somehow instead convert them like unsigned numbers and do like what this answer says to do.

There are also a couple of other questions that I got from reading the linked question. I put them in block quotes. I'm just asking for information on what they mean, and explain it to me.

Firstly

I know that the r-1 complement for r-base number should do end around carry if the highest bit has carry.

Secondly

End-around carry is actually rather simple: it changes the modulus of the addition operation from rn to rn–1.

And lastly

Again, let's keep the carry bit where it is. If you look at the numbers as unsigned integers, we're computing 13 + 11 = 24. However, due to the wrap-around carry, addition is done modulo 15, so we end up with 9, which represents -6 (the correct result).

If someone can explain these quotes to me and provide some web pages for me to read I would greatly appreciate it! :)

Talon Brown
  • 127
  • 13

0 Answers0