Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Please explain this C language left shift program~
Please explain this C language left shift program~

1. Does NN_DIGIT refer to unsigned long integer?

Answer: Yes. UINT4 is defined as unsigned long int, NN_DIGIT is defined as UINT4

unsigned long int -> UINT4 -> NN_DIGIT

Code typedef UINT4 NN_DIGIT;

/* UINT4 defines a four byte word */

typedef unsigned long int UINT4;

2. What do "*a++" and "*b++" mean in the code? (Because the compilation shows an ERROR that cannot be used as the left operand, the code is probably more COMMON, so you can only look at it directly - -)

Answer: *a++ is equivalent to *a; a++; In this program, the assignment of *a is completed first and then the pointer a is moved back one unit.

*b++ is the same as *a++.

I also want to ask what NN_DIGIT *a is? "*a++ = (temp << c) | carry;" This sentence looks like a like an array address. Is a an array?

Answer: NN_DIGIT *a defines a as a 4-byte long integer pointer.

"*a++ = (temp << c) | carry;" This sentence looks like a like an array address: it can only be seen that a is an address, a may be an integer array, but it is not definitely.

NN_DIGIT NN_LShift (a, b, c, digits)

NN_DIGIT *a, *b;

unsigned int c, digits; //digits should be understood is the number of integer units participating in the operation (when a is an array, it can be understood as the length of the array)

{

NN_DIGIT temp, carry = 0; //carry: carry (shifted out) data)

unsigned int t;

if(c < NN_DIGIT_BITS) //NN_DIGIT_BITS: No definition is given, it should be an integer number of Bits, which is 32

if(digits) {

t = NN_DIGIT_BITS - c;

/*

There is a problem here, which is the storage of data when a and b are arrays question. According to the understanding of the code, the long integer should be used as a basic calculation unit. When storing, the low bit is first and the high bit is last.

*/

do {

temp = *b++; // Equivalent to temp = b[i]; i++;

*a++ = (temp << c) | carry; //a[j] = (temp << c) | carry; j++;

carry = c ? (temp >> t) : 0; //When c=0, the carry is zero, otherwise it is the carry number

}while(--digits); //Loop through all data units

}

< p> return (carry);

}