tcl::mathfunc double
Gives a number as a float.
tcl::mathfunc::double NUMBER
expr {double(NUMBER)}
Description
Gives NUMBER as a double. An integer gets the nearest double, and an integer too large for a double is an error. Use it to make / divide as floats: double(1) / 3.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| NUMBER | number | required | An integer or a float. |
Returns
A float.
Examples
% expr {double(3)}
3.0
% expr {double(1) / 3}
0.3333333333333333
% expr {double("0x10")}
16.0
Errors
% expr {double(2**1024)}
floating-point value too large to represent
-errorcode NONE
# Tcl 9.1 only
% expr {double("x")}
cannot use non-numeric string "x" as operand of "double"
-errorcode ARITH DOMAIN {non-numeric string}
# Tcl 8.6 only
% expr {double("x")}
can't use non-numeric string as operand of "double"
-errorcode ARITH DOMAIN {non-numeric string}
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1