PHP log1p() 函数
log1p() 函数是预定义的 PHP 数学函数,返回 log(1+number)。即使 $number 的值接近于零,它也可以精确计算。
语法
log1p(number);
参数 | 描述 | 必需/可选 |
---|---|---|
number | 指定要处理的数字 | 必需 |
示例1
<?php
num=6;
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log1p($num);
?>
输出:
Your number is: 6
By using log10() function your number is : 1.9459101490553
示例2
<?php
num=(-0.3);
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log1p($num);
?>
输出:
Your number is: -0.3
By using log10() function your number is : -0.35667494393873
示例3
<?php
num=(2.7183);
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log1p($num);
?>
输出:
Your number is: 2.7183
By using log10() function your number is : 1.3132665745863
示例4
<?php
num=0;
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log1p($num);
?>
输出:
Your number is: 0
By using log10() function your number is : 0