tcl::mathfunc ldexpTcl 9.1 only
Gives a number times 2 to the power of an integer.
tcl::mathfunc::ldexp X EXP
expr {ldexp(X, EXP)}
Description
Gives X times 2 raised to EXP. EXP must be an integer. It is the inverse of frexp. A result too large for a double is Inf.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| X | number | required | The number. |
| EXP | integer | required | The power of 2. |
Returns
A float.
Examples
% expr {ldexp(0.625, 4)}
10.0
% expr {ldexp(3, -1)}
1.5
% expr {ldexp(1, 2000)}
Inf
Errors
% expr {ldexp(1, 1.5)}
expected integer but got "1.5"
-errorcode TCL VALUE INTEGER
% expr {ldexp(1, 2**70)}
integer value too large to represent
-errorcode ARITH IOVERFLOW {integer value too large to represent}
% expr {ldexp(1)}
not enough arguments for math function "ldexp"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 only.
- Since
- ztcl 1.0.0-beta.1