Positron Compiler Documentation

fAbs

Positron8 · Revision 4.0.6.5 · PDF page 96

Assignment Variable = fAbs(pVariable)

Return the absolute value of a constant, variable or expression as floating point.

pVariable can be a constant, variable or expression. Assignment Variable can be any valid variable type.

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

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
View original PDF page 96Open page in PDFOriginal PDF page 96