round

OPL function to return the nearest integer

Purpose

OPL function to return the nearest integer.

type
float

Syntax

round(float f)

Description

Returns the nearest integer to 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 roundofa=round(a);
float roundofb=round(b);

execute
{
   writeln("round(",a,") gives ",roundofa);
   writeln("round(",b,") gives ",roundofb); 
}

Result

round(-2.5) gives -2
round(3.5) gives 4