dAcos
Syntax
Assignment Variable = dAcos(pVariable)
Overview
Deduce the Arc Cosine of a 64-bit 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 64-bit floating point dAcos is in radians. The value must be in the range of -1 to +1 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 DoubleIn as Double
' Holds the value to Acos
Dim DoubleOut as Double
' Holds the result of the Acos
PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX) ' Make Pin RB14 U1TX
DoubleIn = 0.8
' Load the variable
DoubleOut = dAcos(DoubleIn)
' Extract the Acos of the value
HrsoutLn Dec DoubleOut
' Display the result on a serial terminal
Notes.
64-bit floating point trigonometry is very 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 = (dAcos(MyVar1)) + (dSin(MyVar2))