使用 C 的 Code Composer Studio 的麻烦者

问题描述 投票:0回答:1

我是使用 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”

c settings
1个回答
0
投票

printf set to nofloat needed to be on full. Thanks to Gerhardh. Hit the nail on the head.

© www.soinside.com 2019 - 2024. All rights reserved.