Positron Compiler Documentation

Ceil

Source: Positron16 Compiler User Manual, PDF page 100

Syntax

Assignment Variable = Ceil(pVariable)

Overview

Deduce the ceil of a 32-bit floating point value. Returns the smallest whole value greater than or equal to Variable.

Parameter

pVariable can be a floating point constant, variable or expression. 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 FloatIn as Float
                                ' Holds the value to Ceil
Dim FloatOut as Float
                                ' Holds the result of the Ceil
PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)  ' Make Pin RB14 U1TX
FloatIn = 3.8
                                ' Load the variable
FloatOut = Ceil(FloatIn)
                                ' Extract the ceil value
Hrsout Dec FloatOut, 13
                                ' Display the result (4.0)

Note.

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 = (Ceil(MyVar1)) + (Sin(MyVar2))