[expr] "raise to power" operator, similar to [pow] function Returns an integer value if both arguments are integers, and [double]-precision floating-point otherwise. The left operand may be any integer from Tcl's unlimited integer range. The right operand is limited to a max integer value of 268435455 (0xfffffff) (28 bits). (Unless the left operand is -1, 0, or 1, so that the answer is trivial). Expect to wait a long while for [[expr 2**0xfffffff]] to return. During early 2009, a thread broke out in the comp.lang.tcl usenet group discussing the observation that Tcl's calculation for ====== puts [expr {-2**2}] ====== surprised someone who was expecting the same results as algebra (or even [perl]). Instead of the results being '''-4''' , Tcl returns '''4'''. The reason has to do with the operator precedence between the [-] and '''**''' operators. [ZB] Either I can't count - feel free to correct me in such case - or indeed TCL is right: (-2)^2 = (-2)*(-2) = 4 So why such "surprise", actually? [AMG]: `(-2)**2 = 4`, but `-(2**2) = -4`. [LV] The issue is that, algebraically, the '''-''' is expected to bind last. I know '''I''' was surprised to learn that ... but it's been over 30 years since I was in a math class and I've grown to think of things as Tcl sees them rather than as apparently the math world sees them. [RS] Even thornier, the issue.. in for example 2 * -3 you cannot but first apply the unary minus, then multiplication. [AMG]: There are other disagreements over operator precedence. [&] and [|] are quite nasty: %|Expression |Result|Comment |% &|expr 5&2==2 |1 |expression without parentheses|& &|expr 5&(2==2)|1 |actual behavior of Tcl and [C]|& &|expr (5&2)==2|0 |naively expected behavior |& ---- !!!!!! %| [Category Operator] | [Category Command] | [Category Mathematics] |% !!!!!!