expr(3tcl) Tcl Built-In Commands expr(3tcl) ______________________________________________________________________________ NAME expr - SYNOPSIS expr arg ?arg arg ...? ______________________________________________________________________________ DESCRIPTION (concatenate) arg ()Tcl (evaluate) Tcl C C () expr 8.2 + 6 14.2. Tcl C Tcl OPERANDS Tcl ()( 0)( 0x) ANSI C ((installation) fFl L ): 2.13.6e47.91e+16() : [1] [2] Tcl $ [3] [4] [5] Tcl [6] sin($x) () a 3 b 6 expr 3.1 + $a 6.1 expr 2 + "$a.$b" 5.6 expr 4*[llength "6 2"] 8 expr {{word one} < "word $a"}0 OPERATORS : - + ~ ! (Unary)(bit- wise) NOT NOT NOT * / % + - << >> (propagate) < > <= >= Boolean 1 0 == != Boolean / & ^ | && 1 0 boolean () || 0 1 boolean () x?y:z If-then-else C x y z x C (group) expr 4*2 < 7 0. &&, ||, ?: "" C expr {$v ? [a] : [b]} [a] [b] $v Tcl expr [a] [b] MATH FUNCTIONS Tcl : abs cosh log sqrt acos double log10 srand asin exp pow tan atan floor rand tanh atan2 fmod round ceil hypot sin cos int sinh abs(arg) arg Arg acos(arg) arg [0,pi] Arg [-1,1] .TP asin(arg) arg [-pi/2,pi/2] Arg [-1,1] atan(arg) arg [-pi/2,pi/2] atan2(x, y) y/x [-pi,pi] x y 0 ceil(arg) arg cos(arg) arg cosh(arg) arg double(arg) arg arg arg exp(arg) arg e**arg floor(arg) arg fmod(x, y) x y y 0 hypot(x, y) (x*x+y*y) int(arg) arg argarg () log(arg) arg Arg log10(arg) arg 10 ()Arg pow(x, y) x y x y rand() 1 ()[0,1) srand round(arg) arg arg arg sin(arg) arg sinh(arg) arg sqrt(arg) arg Arg srand(arg) arg tan(arg) arg tanh(arg) arg Tcl_CreateMathFunc () TYPES, OVERFLOW, PRECISION C long C double Tcl C expr 5 / 4 1 expr 5 / 4.0 expr 5 / ( [string length "abcd"] + 0.0 ) 1.25 "." e expr 20.0/5.0 4.0, 4. STRING OPERATIONS C sprintf %d %g expr {"0x03" > "2"} expr {"0y" < "0x12"} 1 18 Tcl == string PERFORMANCE CONSIDERATIONS Tcl : Tcl expr set a 3 set b {$a + 2} expr $b*4 11 4 Tcl b $a + 2 expr $a + 2*4 (emit) KEYWORDS arithmetic, boolean, compare, expression, fuzzy comparison [] [] 2001/07/22 Linux man : http://cmpp.linuxforum.net man man https://github.com/man-pages-zh/manpages- zh Tcl 8.3 expr(3tcl)