power(x,n)

x = Any number

n = Any number

 

Returns x to the power of n. In computers this is often written x^n. At school they probably taught you to write xn.

 

If either x or n or both are 0, the result is 1. If n is positive x is multiplied with itself n times. If n is negative 1 is divided n times by x.

 

Example #1:

foo = 10;

bar = 4;

show_message(string(power(foo,bar))); // 104 = 10*10*10*10 = 10000

 

foo = 4.5;

bar = 0;

show_message(string(power(foo,bar))); // 4.5 * 4.5 * 4.5 * 4.5 = 410,0625

 

foo = 2;

bar = -4;

show_message(string_format(power(foo,bar),5,4)); // 2^-4 = 1 / (2*2*2*2) = 0.0625

 

tsg1zzn / Mithunder - Revision #2