Positron Compiler Documentation

ICos

Positron16 · Revision 1.1.3.5 · PDF page 113

Assignment Variable = ICos(pVariable)

Deduce the integer Cosine of an integer value

pVariable can be a constant, variable or expression that requires the Cosine extracted. The value expected and returned by ICos is in decimal radians (0 to 255). Assignment Variable can be any valid variable type.

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 ByteIn as Byte             ' Holds the value to Cos
Dim ByteOut as Byte             ' Holds the result of the Cos

PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX

ByteIn = 123                   ' Load the variable
ByteOut = ICos(ByteIn)        ' Extract the integer Cosine of the value
HrsoutLn Dec ByteOut           ' Display the result

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 = (ICos(MyVar1)) + MyVar2
View original PDF page 113Open page in PDFOriginal PDF page 113