有人可以向我解释在这种情况下“n”发生了什么吗?
主程序
unsigned long temp0;
PLLSYS0_FWD_DIV_A_DECODE(n);
主文件
#define PLLSYS0_FWD_DIV_A_DECODE(n) ((((unsigned long)(n))>>8)& 0x0000000f)
我知道 n 被移动了 8 位,然后与 0x0000000f 相加。那么 (unsigned long)(n) 实际上做了什么?
#include <stdio.h>
int main(void)
{
unsigned long test1 = 1;
printf("test1 = %d \n", test1);
printf("(unsigned long)test1 = %d \n", (unsigned long)(test1));
return 0;
}
输出:
test1 = 1
(unsigned long)test1 = 1