beetlebug▾
/

tcl::mathfunc acos

Gives the arc cosine of a number, in radians.

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

Description

Gives the angle from 0 to pi whose cosine is NUMBER. NUMBER must be from -1 to 1.

Arguments

ArgumentTypeDefaultDescription
NUMBERnumberrequiredA number from -1 to 1.

Returns

A float from 0 to pi.

Examples

% expr {acos(1)}
0.0

% expr {acos(-1)}
3.141592653589793

% expr {acos(0.5)}
1.0471975511965979

Errors

% expr {acos(2)}
domain error: argument not in valid range
-errorcode ARITH DOMAIN {domain error: argument not in valid range}

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

# Tcl 8.6 only
% expr {acos("x")}
can't use non-numeric string as operand of "acos"
-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