floatValue
OPL function to convert a string to a float
Purpose
OPL function to convert a string to a float.
| type |
|---|
float |
Syntax
floatValue(string)
Description
Converts a string to a float value, if possible. You can use this function within IBM ILOG Script statements by specifying the OPL namespace:
( Opl.xxx() )
Example
string a="-2.5";
string b="3.5";
string c="-1.523456e4";
float floatValueofa=floatValue(a);
float floatValueofb=floatValue(b);
float floatValueofc=floatValue(c);
execute
{
writeln("floatValue(\"",a,"\") gives ",floatValueofa);
writeln("floatValue(\"",b,"\") gives ",floatValueofb);
writeln("floatValue(\"",c,"\") gives ",floatValueofc);
}
Result
floatValue("-2.5") gives -2.5
floatValue("3.5") gives 3.5
floatValue("-1.523456e4") gives -15234.56