beetlebug▾
/

tcl::mathfunc wide

Gives the integer part of a number, cut to 64 bits.

tcl::mathfunc::wide NUMBER
expr {wide(NUMBER)}

Description

Cuts the fraction part off NUMBER, toward zero, and keeps the low 64 bits of the integer as a signed integer. A value outside the range of 64 bits wraps around: wide(2**63) is the smallest 64-bit integer.

Arguments

ArgumentTypeDefaultDescription
NUMBERnumberrequiredAn integer or a finite float.

Returns

An integer from -2*63 to 2*63-1.

Examples

% expr {wide(3.9)}
3

% expr {wide(-3.9)}
-3

% expr {wide(2**63)}
-9223372036854775808

% expr {wide(2**64 + 5)}
5

Errors

# Tcl 9.1 only
% expr {wide("x")}
cannot use non-numeric string "x" as operand of "wide"
-errorcode ARITH DOMAIN {non-numeric string}

# Tcl 8.6 only
% expr {wide("x")}
can't use non-numeric string as operand of "wide"
-errorcode ARITH DOMAIN {non-numeric string}

% expr {wide()}
not enough arguments for math function "wide"
-errorcode TCL WRONGARGS

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also