
        _N_A_M_E

              expr - Evaluate an expression

        _S_Y_N_O_P_S_I_S

              eexxpprrarg?arg arg ...?

        _D_E_S_C_R_I_P_T_I_O_N
        _O_P_E_R_A_N_D_S
        _O_P_E_R_A_T_O_R_S

              _--_ _++_ _~~_ _!!
              _**_ _//_ _%%
              _++_ _--
              _<<_<<_ _>>_>>
              _<<_ _>>_ _<<_==_ _>>_==
              _==_==_ _!!_==
              _&&
              _^^
              _||
              _&&_&&
              _||_||
              _x_??_y_::_z

        _M_A_T_H_ _F_U_N_C_T_I_O_N_S

              _aa_bb_ss_((_a_r_g_))
              _aa_cc_oo_ss_((_a_r_g_))
              _aa_ss_ii_nn_((_a_r_g_))
              _aa_tt_aa_nn_((_a_r_g_))
              _aa_tt_aa_nn_22_((_x_,_ _y_))
              _cc_ee_ii_ll_((_a_r_g_))
              _cc_oo_ss_((_a_r_g_))
              _cc_oo_ss_hh_((_a_r_g_))
              _dd_oo_uu_bb_ll_ee_((_a_r_g_))
              _ee_xx_pp_((_a_r_g_))
              _ff_ll_oo_oo_rr_((_a_r_g_))
              _ff_mm_oo_dd_((_x_,_ _y_))
              _hh_yy_pp_oo_tt_((_x_,_ _y_))
              _ii_nn_tt_((_a_r_g_))
              _ll_oo_gg_((_a_r_g_))
              _ll_oo_gg_11_00_((_a_r_g_))
              _pp_oo_ww_((_x_,_ _y_))
              _rr_aa_nn_dd_((_))
              _rr_oo_uu_nn_dd_((_a_r_g_))
              _ss_ii_nn_((_a_r_g_))
              _ss_ii_nn_hh_((_a_r_g_))
              _ss_qq_rr_tt_((_a_r_g_))
              _ss_rr_aa_nn_dd_((_a_r_g_))
              _tt_aa_nn_((_a_r_g_))
              _tt_aa_nn_hh_((_a_r_g_))

        _T_Y_P_E_S_,_ _O_V_E_R_F_L_O_W_,_ _A_N_D_ _P_R_E_C_I_S_I_O_N
        _S_T_R_I_N_G_ _O_P_E_R_A_T_I_O_N_S
        _P_E_R_F_O_R_M_A_N_C_E_ _C_O_N_S_I_D_E_R_A_T_I_O_N_S
        _K_E_Y_W_O_R_D_S

  ---------------------------------------------------------------------------

  NNAAMMEE

  expr - Evaluate an expression

  SSYYNNOOPPSSIISS

  eexxpprrarg?arg arg ...?

  DDEESSCCRRIIPPTTIIOONN

  Concatenates arg's (adding separator spaces between them), evaluates the
  result as a Tcl expression, and returns the value. The operators permitted
  in Tcl expressions are a subset of the operators permitted in C
  expressions, and they have the same meaning and precedence as the
  corresponding C operators. Expressions almost always yield numeric results
  (integer or floating-point values). For example, the expression

    eexxpprr 88..22 ++ 66

  evaluates to 14.2. Tcl expressions differ from C expressions in the way
  that operands are specified. Also, Tcl expressions support non-numeric
  operands and string comparisons.

  OOPPEERRAANNDDSS

  A Tcl expression consists of a combination of operands, operators, and
  parentheses. White space may be used between the operands and operators and
  parentheses; it is ignored by the expression's instructions. Where
  possible, operands are interpreted as integer values. Integer values may be
  specified in decimal (the normal case), in octal (if the first character of
  the operand is 00), or in hexadecimal (if the first two characters of the
  operand are 00xx). If an operand does not have one of the integer formats
  given above, then it is treated as a floating-point number if that is
  possible. Floating-point numbers may be specified in any of the ways
  accepted by an ANSI-compliant C compiler (except that the ff, FF, ll, and LL
  suffixes will not be permitted in most installations). For example, all of
  the following are valid floating-point numbers: 2.1, 3., 6e4, 7.91e+16. If
  no numeric interpretation is possible, then an operand is left as a string
  (and only a limited set of operators may be applied to it).

  Operands may be specified in any of the following ways:



    [1]
        As an numeric value, either integer or floating-point.

    [2]
        As a Tcl variable, using standard $$ notation. The variable's value
        will be used as the operand.

    [3]
        As a string enclosed in double-quotes. The expression parser will
        perform backslash, variable, and command substitutions on the
        information between the quotes, and use the resulting value as the
        operand

    [4]
        As a string enclosed in braces. The characters between the open brace
        and matching close brace will be used as the operand without any
        substitutions.

    [5]
        As a Tcl command enclosed in brackets. The command will be executed
        and its result will be used as the operand.

    [6]
        As a mathematical function whose arguments have any of the above
        forms for operands, such as ssiinn(($$xx)). See below for a list of defined
        functions.


  Where substitutions occur above (e.g. inside quoted strings), they are
  performed by the expression's instructions. However, an additional layer of
  substitution may already have been performed by the command parser before
  the expression processor was called. As discussed below, it is usually best
  to enclose expressions in braces to prevent the command parser from
  performing substitutions on the contents.

  For some examples of simple expressions, suppose the variable aa has the
  value 3 and the variable bb has the value 6. Then the command on the left
  side of each of the lines below will produce the value on the right side of
  the line:

    eexxpprr 33..11 ++ $$aa		66..11
    eexxpprr 22 ++ ""$$aa..$$bb""		55..66
    eexxpprr 44**[[lllleennggtthh ""66 22""]]		88
    eexxpprr {{{{wwoorrdd oonnee}} << ""wwoorrdd $$aa""}}		00

  OOPPEERRAATTOORRSS

  The valid operators are listed below, grouped in decreasing order of
  precedence:



    -- ++ ~~ !!
        Unary minus, unary plus, bit-wise NOT, logical NOT. None of these
        operands may be applied to string operands, and bit-wise NOT may be
        applied only to integers.

    ** // %%
        Multiply, divide, remainder. None of these operands may be applied to
        string operands, and remainder may be applied only to integers. The
        remainder will always have the same sign as the divisor and an
        absolute value smaller than the divisor.

    ++ --
        Add and subtract. Valid for any numeric operands.

    <<<< >>>>
        Left and right shift. Valid for integer operands only. A right shift
        always propagates the sign bit.

    << >> <<== >>==
        Boolean less, greater, less than or equal, and greater than or equal.
        Each operator produces 1 if the condition is true, 0 otherwise. These
        operators may be applied to strings as well as numeric operands, in
        which case string comparison is used.

    ==== !!==
        Boolean equal and not equal. Each operator produces a zero/one
        result. Valid for all operand types.

    &&
        Bit-wise AND. Valid for integer operands only.

    ^^
        Bit-wise exclusive OR. Valid for integer operands only.

    ||
        Bit-wise OR. Valid for integer operands only.

    &&&&
        Logical AND. Produces a 1 result if both operands are non-zero, 0
        otherwise. Valid for boolean and numeric (integers or floating-point)
        operands only.

    ||||
        Logical OR. Produces a 0 result if both operands are zero, 1
        otherwise. Valid for boolean and numeric (integers or floating-point)
        operands only.

    x??y::z
        If-then-else, as in C. If x evaluates to non-zero, then the result is
        the value of y. Otherwise the result is the value of z. The x operand
        must have a numeric value.


  See the C manual for more details on the results produced by each operator.
  All of the binary operators group left-to-right within the same precedence
  level. For example, the command

    eexxpprr 44**22 << 77
  returns 0.

  The &&&&, ||||, and ??:: operators have ``lazy evaluation'', just as in C, which
  means that operands are not evaluated if they are not needed to determine
  the outcome. For example, in the command

    eexxpprr {{$$vv ?? [[aa]] :: [[bb]]}}
  only one of [[aa]] or [[bb]] will actually be evaluated, depending on the value
  of $$vv. Note, however, that this is only true if the entire expression is
  enclosed in braces; otherwise the Tcl parser will evaluate both [[aa]] and [[bb]]
  before invoking the eexxpprr command.

  MMAATTHH FFUUNNCCTTIIOONNSS

  Tcl supports the following mathematical functions in expressions:

    aabbss

  ccoosshh

  lloogg

  ssqqrrtt
  aaccooss

  ddoouubbllee

  lloogg1100

  ssrraanndd
  aassiinn

  eexxpp

  ppooww

  ttaann
  aattaann

  fflloooorr

  rraanndd

  ttaannhh
  aattaann22

  ffmmoodd

  rroouunndd
  cceeiill

  hhyyppoott

  ssiinn
  ccooss

  iinntt

  ssiinnhh



    aabbss((arg))
        Returns the absolute value of arg. Arg may be either integer or
        floating-point, and the result is returned in the same form.

    aaccooss((arg))
        Returns the arc cosine of arg, in the range [0,pi] radians. Arg
        should be in the range [-1,1].

    aassiinn((arg))
        Returns the arc sine of arg, in the range [-pi/2,pi/2] radians. Arg
        should be in the range [-1,1].

    aattaann((arg))
        Returns the arc tangent of arg, in the range [-pi/2,pi/2] radians.

    aattaann22((x, y))
        Returns the arc tangent of y/x, in the range [-pi,pi] radians. x and
        y cannot both be 0.

    cceeiill((arg))
        Returns the smallest integer value not less than arg.

    ccooss((arg))
        Returns the cosine of arg, measured in radians.

    ccoosshh((arg))
        Returns the hyperbolic cosine of arg. If the result would cause an
        overflow, an error is returned.

    ddoouubbllee((arg))
        If arg is a floating value, returns arg, otherwise converts arg to
        floating and returns the converted value.

    eexxpp((arg))
        Returns the exponential of arg, defined as e**arg. If the result
        would cause an overflow, an error is returned.

    fflloooorr((arg))
        Returns the largest integral value not greater than arg.

    ffmmoodd((x, y))
        Returns the floating-point remainder of the division of x by y. If y
        is 0, an error is returned.

    hhyyppoott((x, y))
        Computes the length of the hypotenuse of a right-angled triangle
        (x*x+y*y).

    iinntt((arg))
        If arg is an integer value, returns arg, otherwise converts arg to
        integer by truncation and returns the converted value.

    lloogg((arg))
        Returns the natural logarithm of arg. Arg must be a positive value.

    lloogg1100((arg))
        Returns the base 10 logarithm of arg. Arg must be a positive value.

    ppooww((x, y))
        Computes the value of x raised to the power y. If x is negative, y
        must be an integer value.

    rraanndd(())
        Returns a floating point number from zero to just less than one or,
        in mathematical terms, the range [0,1). The seed comes from the
        internal clock of the machine or may be set manual with the srand
        function.

    rroouunndd((arg))
        If arg is an integer value, returns arg, otherwise converts arg to
        integer by rounding and returns the converted value.

    ssiinn((arg))
        Returns the sine of arg, measured in radians.

    ssiinnhh((arg))
        Returns the hyperbolic sine of arg. If the result would cause an
        overflow, an error is returned.

    ssqqrrtt((arg))
        Returns the square root of arg. Arg must be non-negative.

    ssrraanndd((arg))
        The arg, which must be an integer, is used to reset the seed for the
        random number generator. Returns the first random number from that
        seed. Each interpreter has it's own seed.

    ttaann((arg))
        Returns the tangent of arg, measured in radians.

    ttaannhh((arg))
        Returns the hyperbolic tangent of arg.


  In addition to these predefined functions, applications may define
  additional functions using _TT_cc_ll____CC_rr_ee_aa_tt_ee_MM_aa_tt_hh_FF_uu_nn_cc().

  TTYYPPEESS,, OOVVEERRFFLLOOWW,, AANNDD PPRREECCIISSIIOONN

  All internal computations involving integers are done with the C type long,
  and all internal computations involving floating-point are done with the C
  type double. When converting a string to floating-point, exponent overflow
  is detected and results in a Tcl error. For conversion to integer from
  string, detection of overflow depends on the behavior of some routines in
  the local C library, so it should be regarded as unreliable. In any case,
  integer overflow and underflow are generally not detected reliably for
  intermediate results. Floating-point overflow and underflow are detected to
  the degree supported by the hardware, which is generally pretty reliable.

  Conversion among internal representations for integer, floating-point, and
  string operands is done automatically as needed. For arithmetic
  computations, integers are used until some floating-point number is
  introduced, after which floating-point is used. For example,

    eexxpprr 55 // 44
  returns 1, while

    eexxpprr 55 // 44..00
    eexxpprr 55 // (( [[ssttrriinngg lleennggtthh ""aabbccdd""]] ++ 00..00 ))
  both return 1.25. Floating-point values are always returned with a ``..'' or
  an ee so that they will not look like integer values. For example,

    eexxpprr 2200..00//55..00
  returns 44..00, not 44.

  SSTTRRIINNGG OOPPEERRAATTIIOONNSS

  String values may be used as operands of the comparison operators, although
  the expression evaluator tries to do comparisons as integer or floating-
  point when it can. If one of the operands of a comparison is a string and
  the other has a numeric value, the numeric operand is converted back to a
  string using the C sprintf format specifier %%dd for integers and %%gg for
  floating-point values. For example, the commands

    eexxpprr {{""00xx0033"" >> ""22""}}
    eexxpprr {{""00yy"" << ""00xx1122""}}

  both return 1. The first comparison is done using integer comparison, and
  the second is done using string comparison after the second operand is
  converted to the string 1188. Because of Tcl's tendency to treat values as
  numbers whenever possible, it isn't generally a good idea to use operators
  like ==== when you really want string comparison and the values of the
  operands could be arbitrary; it's better in these cases to use the _ss_tt_rr_ii_nn_gg
  command instead.

  PPEERRFFOORRMMAANNCCEE CCOONNSSIIDDEERRAATTIIOONNSS

  Enclose expressions in braces for the best speed and the smallest storage
  requirements. This allows the Tcl bytecode compiler to generate the best
  code.

  As mentioned above, expressions are substituted twice: once by the Tcl
  parser and once by the eexxpprr command. For example, the commands

    sseett aa 33
    sseett bb {{$$aa ++ 22}}
    eexxpprr $$bb**44
  return 11, not a multiple of 4. This is because the Tcl parser will first
  substitute $$aa ++ 22 for the variable bb, then the eexxpprr command will evaluate
  the expression $$aa ++ 22**44.

  Most expressions do not require a second round of substitutions. Either
  they are enclosed in braces or, if not, their variable and command
  substitutions yield numbers or strings that don't themselves require
  substitutions. However, because a few unbraced expressions need two rounds
  of substitutions, the bytecode compiler must emit additional instructions
  to handle this situation. The most expensive code is required for unbraced
  expressions that contain command substitutions. These expressions must be
  implemented by generating new code each time the expression is executed.

  KKEEYYWWOORRDDSS

  _a_r_i_t_h_m_e_t_i_c, _b_o_o_l_e_a_n, _c_o_m_p_a_r_e, _e_x_p_r_e_s_s_i_o_n, _f_u_z_z_y_ _c_o_m_p_a_r_i_s_o_n
  ---------------------------------------------------------------------------

    _C_o_p_y_r_i_g_h_t  1993 The Regents of the University of California.
    _C_o_p_y_r_i_g_h_t  1994-2000 Sun Microsystems, Inc.
    _C_o_p_y_r_i_g_h_t  1995-1997 Roger E. Critchlow Jr.

