Documentation

TRUNC

Function name

TRUNC

ST call

PROGRAM TRUNC_DEMO
VAR
REAL1: REAL;
D1: DINT;
END_VAR
D1:= TRUNC(IN:=REAL1);
END_PROGRAM

Description

Returns the input value truncated to a whole number, cutting off the decimal part.

Inputs

Input Type Description
IN ANY_REAL Input value

Outputs

Output Type Description
=> DINT Output value

Application example

Calculation example

Input value round ( _TO_ ) floor ceil trunc
5.5 6 5 6 5
3.8 4 3 4 3
2.3 2 2 3 3
-2.3 -2 -3 -2 -2
-3.8 -4 -4 -3 -3
-5.5 -6 -6 -5 -5