abs

OPL function for the absolute value

Purpose

OPL function for the absolute value.

type
float

Syntax

abs(float f)

Description

Returns the absolute value of f.

You can use this function within IBM ILOG Script statements by specifying the OPL namespace:


( Opl.xxx() )

Example

float a=-2;
float b=3.5;

float absofa=abs(a);
float absofb=abs(b);

execute
{
   writeln("abs(",a,") gives ",absofa);
   writeln("abs(",b,") gives ",absofb); 
}

Result

abs(-2) gives 2
abs(3.5) gives 3.5