tcl::mathfunc log
Gives the natural logarithm of a number.
tcl::mathfunc::log NUMBER
expr {log(NUMBER)}
Description
Gives the logarithm of NUMBER to the base e. log(0) is -Inf, and a negative number is a domain error. An integer too large for a double gives Inf.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| NUMBER | number | required | A number, 0 or more. |
Returns
A float.
Examples
% expr {log(1)}
0.0
% expr {log(10)}
2.302585092994046
% expr {log(0)}
-Inf
Errors
% expr {log(-1)}
domain error: argument not in valid range
-errorcode ARITH DOMAIN {domain error: argument not in valid range}
# Tcl 9.1 only
% expr {log("x")}
cannot use non-numeric string "x" as operand of "log"
-errorcode ARITH DOMAIN {non-numeric string}
# Tcl 8.6 only
% expr {log("x")}
can't use non-numeric string as operand of "log"
-errorcode ARITH DOMAIN {non-numeric string}
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1