Power
The function Power returns the result of aValue raised to the exponent power of aPower.
This is the reverse of the function NthRoot.
So the result of the function Power(10,3) or 10^3 is the result of 1,000.
If the result is a nonsense or imaginary number, the result will be the value NAN which is an acronym for Not A Number.
Declaration: Function Power(const aValue : Extended; const aPower : Integer) : Extended;
Examples follow.
procedure
ScriptEvent (
var
Value : variant);
var
NewInt :
integer
;
NewExt, NextExt :
extended
;
begin
LogInfo(
'The POWER value of 10^3'
);
NewInt :=
3
;
NewExt :=
10
;
NextExt := Power(NewExt, NewInt);
LogInfo(
'Result = '
+FloatToStr(NextExt));
//Displays 'Result = 1000'
LogInfo(
''
);
LogInfo(
'The POWER value of 10^2'
);
NewInt :=
2
;
NewExt :=
10
;
NextExt := Power(NewExt, NewInt);
LogInfo(
'Result = '
+FloatToStr(NextExt));
//Displays 'Result = 100'
LogInfo(
''
);
LogInfo(
'The POWER value of -1^2 - will FAIL'
);
NewInt :=
2
;
NewExt := -
1
;
//Returns i (an imaginary number)
NextExt := NthRoot(NewInt, NewExt);
LogInfo(
'Result = '
+FloatToStr(NextExt));
//Displays 'Result = NAN'
LogInfo(
''
);
end
;