Pow
Syntax
Assignment Variable = Pow (pVariable, pPowValue)
Overview
Computes 32-bit FloatIng point Variable to the power of Pow Variable.
Parameters
pVariable can be a constant, variable or expression that holds the variable to power. pPowValue can be a constant, variable or expression that holds the amount of powers required. Assignment Variable can be any valid variable type.
Example
Device = 24FJ64GA002
' Select the device to compile for
Declare Xtal = 16
' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600 ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim fPowOf as Float
Dim FloatIn as Float
' Holds the value to Pow with
Dim FloatOut as Float
' Holds the result of the Pow
RPOR7 = 3
' Make PPS Pin RP14 U1TX
fPowOf= 10
FloatIn = 2
' Load the variable
FloatOut = Pow(FloatIn, fPowOf)
' Extract the Pow of the value
HrsoutLn Dec FloatOut
' Display the result
Notes.
FloatIng point trigonometry is rather 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.
Note.
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