The thread that Björn is referencing contains all you need to know about calculating with different bases.
One thing we have never talked about on this forum is 2’s complement.
Mental calculation here is easier. Let’s assume we are working in hexadecimal.
A number is negative if the leftmost binary digit is 1. This is the sign bit.
in hexadecimal this translates to the leftmost digit being 8 or higher (so 8, 9, A, B, C, D, E or F).
The negative number is just the distance from zero. Let’s assume we look at byttes. In hexadecimal this means that we can hold a maximum of 2 digits.
“FF” is “-1”.
FF + 1 = 100.
Because we can hold only 2 (hex) digits, 100 is two zero digits with a carry.
We discard the carry, so if we have one byte of space, FF + 1 becomes 00.
Then FE = -2, because FE + 2 = 100. etc.
There are 2 methods for converting a negative number to positive.
First check if the sign bit is indeed set. Again, in hexadecimal, this means a digit of 8 or higher.
If we are working with 2 digit numbers, subtract the number from 100.
So if AE is the number, 100 - AE = 52. If you don’t know how to do this, AE is almost B0. 100 - B0 = 50. Calculating from left to right, we do 10 - B first. 10 in hex is 16 in decimal and B (hex) is 11 decimal and 16 - 11 = 5.
Last step 10 - E (hex) = 16 - 14 (dec) = 2.
With 2 digits, the number to subtract from is 100.
With n digits, the number to subtract from is 10^n (hex). This is a 1 followed by n number of zero’s.
This works best in binary. If our number is AE (hex), in binary this is:
1010 1110. Now convert all zero’'s into one’s and all one’s into zero’s:
0101 0001. Convert back to hexadecimal = 51.
Last step: add one. 51 + 1 = 52.