tcl::mathfunc logbTcl 9.1 only
Gives the binary exponent of a number.
tcl::mathfunc::logb NUMBER
expr {logb(NUMBER)}
Description
Gives the exponent of NUMBER in base 2 as a float: the whole part of log2(abs(NUMBER)). The sign of NUMBER does not count. logb(0) is -Inf, and logb(Inf) is Inf.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| NUMBER | number | required | Any number. |
Returns
A float with no fraction part, or an infinity.
Examples
% expr {logb(10)}
3.0
% expr {logb(-8)}
3.0
% expr {logb(1e-310)}
-1030.0
% expr {logb(0)}
-Inf
Errors
% expr {logb("x")}
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER
% expr {logb()}
not enough arguments for math function "logb"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 only.
- Since
- ztcl 1.0.0-beta.1