Positron Compiler Documentation

Floor

Positron16 · Revision 1.1.3.5 · PDF page 108

Assignment Variable = Floor(pVariable)

Deduce the floor of a 32-bit floating point value. Returns the largest whole value less than or equal to Variable.

pVariable can be a floating point constant, variable or expression. 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 FloatIn as Float           ' Holds the value to Asin
Dim FloatOut as Float           ' Holds the result of the Asin

PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX

FloatIn = 3.8                  ' Load the variable
FloatOut = Floor(FloatIn)      ' Extract the floor value
HrsoutLn Dec FloatOut           ' Display the result (3.0)

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