This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430G2452:简单算术问题

Guru**** 2510075 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/800709/msp430g2452-simple-arithmetic-question

器件型号:MSP430G2452

大家好、我正在使用 IAR。

我想计算2^3=8。 我是说、我尝试进行指数运算。

但我不知道如何执行指数运算。 可以帮帮我吗?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    正如您可能已经发现的那样、C/C++中的 μ^运算符是一个异或函数。 没有指数运算符。

    如果您实际上只是使用整数幂、乘法可能是最快的、并且可以使用整数或浮点:2*2*2

    对于一般指数、您需要使用数学库。 下面是一个简单的程序:

    #include

    MAIN ()

    双精度结果;
    结果= pow (2.0、3.0);


    任何 C 引用都可能会告诉您这一点。