So I'm trying to write code to subtract two binary numbers but I'm not sure how to tackle this problem elegantly. The structures that hold the binary numbers are as follows.
typedef struct _bitb {
short bit;
struct _bitb *nbit;
} BitB;
typedef struct _bignum {
short sign;
BitB *bits;
} BigNum;
Thus a binary number is represented by a list of bits containing its absolute value, from the LSB to the MSB, and then a short that says whether the number is positive or negative (it's an implementation of arbitrary precision arithmetic). How can I subtract one number from the other without two's complement?
And before someone asks, this is for school, but I don't want a solution in code, just a general algorithm that I can implement. I've been searching around and it seems like there isn't a good algorithm that can solve the general case. Do I need to check the signs of the numbers and then implement code for all the possible cases (negative minus positive, positive minus negative, positive minus positive, negative minus positive)? Or should I just convert to 2's complement?