Suppose you wanted to raise the value a to the exponent b. Then suppose you wanted to assign that value to c. Normal math notation for this would look like this:
c = ab
Here is how to do the same thing using EZ Math Movie's power command:
c = power(a, b);
The values for a and b work like this:
If the third rule is broken, that is, if a is negative and has a decimal, power will not return a number. It will return NaN. 'NaN' means 'not a number'. The demonstration program below demonstrate this.
Let's say we wanted to take the square root of 5. One way to do this would be to raise 5 to an exponent of 1/2 or 0.5. Setting a variable named x to this value could look like this:
x = power(5, 0.5);
However, square roots are used so frequently that EZ Math Movie has a special command for it. The command sqrt does that, and it looks like this:
x = sqrt(5);
This example program runs through all the combinatios of positive and negative bases and exponents for the power command. Note that the last two do not work.
The program also shows how to use the sqrt command.
Remember, 'NaN' means 'not a number', and that signals an error in this program.
Next tutorial: Increment, decrement