beetlebug▾
/

tcl::mathfunc entier

Gives the integer part of a number, as an integer of any size.

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

Description

Cuts the fraction part off NUMBER, toward zero, and gives an integer of any size. An integer stays as it is. Inf is an error.

Arguments

ArgumentTypeDefaultDescription
NUMBERnumberrequiredAn integer or a finite float.

Returns

An integer.

Examples

% expr {entier(3.9)}
3

% expr {entier(-3.9)}
-3

% expr {entier(1e20)}
100000000000000000000

Errors

% expr {entier(Inf)}
integer value too large to represent
-errorcode NONE

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

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

Facts

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

See also