fAbs
Positron8 · Revision 4.0.6.5 · PDF page 96
Syntax
Assignment Variable = fAbs(pVariable)
Overview
Return the absolute value of a constant, variable or expression as floating point.
Parameter
pVariable 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 FloatIn as Float ' Create a Floating Point variable
Dim FloatOut as Float ' Create a Floating Point variable
FloatIn = -1234567 ' Load FloatIn with value -1234567
FloatOut = fAbs(FloatIn) ' Extract the absolute value from FloatIn
HRsoutLn Dec FloatOut ' Display the result, which is 1234567
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 = (fAbs(MyVar1)) + MyVar2
