Positron Compiler Documentation

Acos

Source: Positron8 Compiler User Manual, PDF page 97

Syntax

Assignment Variable = Acos(pVariable)

Overview

Deduce the Arc Cosine of a floating point value

Parameter

pVariable can be a constant, variable or expression that requires the Arc Cosine (Inverse Cosine) extracted. The value expected and returned by the floating point Acos is in radians. The value must be in the range of -1 to +1 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 = 0.8
                                ' Holds the value to Acos
Dim Floatout as Float
                                ' Holds the result of the Acos
Floatout = Acos(Floatin)
                                ' Extract the Acos of the value
HRsoutLn Dec Floatout
                                ' Display the result
Stop

Notes

Acos 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 Arc Cosine 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 = (Acos(MyVar1)) + MyVar2