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: Simple arithmetic question

Part Number: MSP430G2452

Hi, iam using IAR.

i would like to calculate 2^3=8. I mean, i'm trying to make an exponential operation.

But i don't know how to do exponential operation. Can you help me?

  • As you might have found out, the ^ operator in C/C++ is an exclusive-or function. There is no exponentiation operator.

    If you are really just using integer powers, multiplication is possibly the fastest and works with integers or floating point: 2*2*2

    For general exponentiation, you need to use the math library. Here is a simple program:

    #include <math.h>

    main()
    {
    double result;
    result = pow(2.0, 3.0);
    }

    Any C reference could have told you this.

**Attention** This is a public forum