Pow
Syntax
Assignment Variable = Pow(pVariable, pPowVariable)
Overview
Computes pVariable to the power of pPowVariable.
Parameters
pVariable can be a constant, variable or expression. pPowVariable can be a constant, variable or expression. Assignment Variable can be any valid variable type.
Example
Device = 18F26K40 ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600 ' Set the Baud rate for HRsoutLn
Dim fPowOf as Float
Dim Floatin as Float ' Holds the value to Pow with
Dim Floatout as Float ' Holds the result of the Pow
fPowOf= 10
Floatin = 2 ' Load the variable
Floatout = Pow(Floatin, fPowOf)' Extract the Pow of the value
HRsoutLn Dec Floatout ' Display the result
Stop
Notes
Pow is not implemented with 12, or 14-bit core devices, however, with the extra functionality, and more linear memory offered by the 18F devices, full 32-bit floating point power of is implemented.
Floating point trigonometry is extremely memory hungry, so do not be surprised if a large chunk of the microcontroller’s code memory is used with a single operator. This also means that floating point trigonometry is comparatively slow to operate.
When implementing trigonometry, or other built in, functions within an expression, always wrap them in parenthesis, otherwise the parser may consider the extra operands as part of the trigonometry parameter and produce an incorrect result. For example:
MyAssignment = (Pow(MyVar1, MyVar2)) + MyVar3
