trunc

OPL function to return the integer part

Purpose

OPL function to return the integer part.

type
float

Syntax

trunc(float f)

Description

Returns the integer part of a given floating-point value. You can use this function within IBM ILOG Script statements by specifying the OPL namespace:


( Opl.xxx() )

Example

float a=-2.5;
float b=3.5;

float truncofa=trunc(a);
float truncofb=trunc(b);

execute
{
   writeln("trunc(",a,") gives ",truncofa);
   writeln("trunc(",b,") gives ",truncofb); 
}

Result

trunc(-2.5) gives -2
trunc(3.5) gives 3