lg

用于表示以 2 为底的对数的 OPL 函数

用途

用于返回以 2 为底的对数的 OPL 函数。

类型
float

语法

lg(float f)

描述

返回浮点值的以 2 为底的对数。 您可以通过指定 OPL 名称空间在 IBM ILOG Script 语句内使用此函数:

( Opl.xxx() )

示例

float a=1;
float b=128;
float c=20;

float lgofa=lg(a);
float lgofb=lg(b);
float lgofc=lg(c);

execute
{
   writeln("lg(",a,") gives ",lgofa);
   writeln("lg(",b,") gives ",lgofb); 
   writeln("lg(",c,") gives ",lgofc); 
}

结果

lg(1) gives 0
lg(128) gives 7
lg(20) gives 4.321928094887363