This is part of 3.33.0latest release.

CEIL

1.1.0
since lib: v0.15.0  

This is a rounding function which returns the smallest possible integer which is greater or equal to `X`.

This is a rounding function which returns the smallest possible integer which is greater or equal to X.

Examples:

CEIL(3.14)    // 4
CEIL(-3.14)   // -3

Version history

1.1.0

  hm

Changes

Changed:
  • use REAL_TO_INT instead of TRUNC for compatibility reasons
show full history

1.0.0

  hm

Changes

Added:
  • original version

Overview

kindnametypedefaultcomment
inputXREALinput value

Details

X

REAL

Input value.

Source code

Declarations

(*Returns the smallest possible integer which is greater or equal to `X`*)
FUNCTION index : INT

(*
 * -----------------------------------------------------------------------------
 * Name               : index
 * Version            : 1.1.0
 * Date               : 2008-03-21
 * Author             : hm
 * 
 * -----------------------------------------------------------------------------
 * Returns the smallest possible integer which is greater or equal to `X`
 * -----------------------------------------------------------------------------
 *)

VAR_INPUT
  X : REAL; (*input value*)
END_VAR

Logic

CEIL := REAL_TO_INT(x);
IF CEIL < X THEN
	CEIL := CEIL + 1;
END_IF;

Implementation

Snippet of the function call:
dummy := CEIL(
           X := );