Question: I need guidance on what I am doing wrong. The wbitadd function is supposed to implement 2's compliment on m and n then add those

I need guidance on what I am doing wrong. The wbitadd function is supposed to implement 2's compliment on m and n then add those two integers together. Some results are correct, some are correct but wrong format and others are completely wrong.
I need guidance on what I am doing wrong. The wbitadd function
is supposed to implement 2's compliment on m and n then add
those two integers together. Some results are correct, some are correct but

long wbitadd(const unsigned char W, const unsigned long m, const unsigned long n, unsigned long result) { int signed long newm = (mm)+1;//change to signed int signed long newn - (n)+1; *result = newm + newn;/add m and n and store in veseid #include int wbitadd(const unsigned char W, const unsigned long m, const unsigned long n, unsigned long *result). int main() { unsigned char w = 28; unsigned long m = Oxffff000; unsigned long n = 0x12307fff000; unsigned long sum; int overflow; overflow = ! wbitadd(w,m,n,&sum); printf("%d-bit Ox%1% + 0x%1x = 0x%1x ",w, m, n, sum); -1x if (overflow) printf("(overflows)"); putchar(' '); return 0; You are to implement a simple function with the following type declaration: long wbitadd(const unsigned char w, const unsigned long m, const unsigned long n, unsigned long result); This function implements two's complement (signed) addition on the second and third arguments, which are interpreted as w-bit signed integers, where w is the first argument. The w-bit result is placed in the location pointed to by the fourth argument. The function returns 0 if the addition operation overflows, and 1 otherwise. In other words, the return value, interpreted as a boolean, indicates whether a valid result has been returned, so it can be used in the following way: if (wbitadd (width, addendi, addend2, &sum)) { // sum contains the valid result } else // handle overflow ) The preconditions for this function, which you may assume are satisfied, are as follows

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!