PHP log1p() Function
The log1p() is an inbuilt PHP function that returns log(1+number), & when the value of the number is close to zero, then it will compute the way that will provide the accurate result.
Syntax:
log1p(float $num): float
Parameter: This function accepts only a single parameter:
- num: This parameter specifies the argument to the process.
Return value: This function returns log(1+number). The result will be in the floating point.
Example 1: The following example demonstrates the log1() function.
PHP
<?php echo log1p(33). "\n" ; echo log1p(33/2) ; ?> |
Output:
3.5263605246162 2.8622008809295
Example 2: The following example demonstrates the log1() function.
PHP
<?php echo log1p(99-50). "\n" ; echo log1p(100+2); ?> |
Output:
3.9120230054281 4.6347289882296
Reference: https://www.php.net/manual/en/function.log1p.php