我是使用 Code Composer Studio 的新手,我需要使用 MSP-EX430F5529P 板来运行一个简单的功能,但它在应该是积极的情况下却给了我消极的结果。我很确定它是项目属性中的错误,但我不知道正确的设置是什么。
#include <stdio.h>
#include <msp430.h>
/**
* hello.c
*/
long CalcPower(int base, int exponent){
long result = 1;
int i = 0;
for(i; i<exponent; i++){
result *= base;
}
return result;
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
int a = 13;
int p = 5;
long b = CalcPower(a, p);
printf("%d to the power of %d is %d\n", a, p, b);
return 0;
}
“13 的 5 次方是 -21923”是我得到的,但我需要“13 的 5 次方是 371293”