beetlebug▾
/

tcl::mathfunc ceil

Gives the smallest whole number at or above a number, as a float.

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

Description

Rounds NUMBER up to a whole number and gives it as a float, also for an integer argument. A large integer loses the digits that a double does not keep. For an integer result, use entier on the result.

Arguments

ArgumentTypeDefaultDescription
NUMBERnumberrequiredAny number.

Returns

A float with no fraction part.

Examples

% expr {ceil(1.2)}
2.0

% expr {ceil(-1.2)}
-1.0

% expr {ceil(3)}
3.0

Errors

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

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

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

Facts

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

See also