lesson 5 :基本数学计算
1. set X 100;
set Y 256;
set Z [expr "$Y + $X"]
//亦可以写成 set Z [expr {$Y +$X}]
2. set Z_LABEL "$Y plus $X is "
puts "$Z_LABEL $Z"
puts "The square root of $Y is [expr sqrt($Y)]\n"
//求开方的算式 expr 外面一般要带上[]作为返回值
3.puts "Because of the precedence rules \"5 + -3 * 4\" is: [expr -3 * 4 + 5]"
puts "Because of the parentheses \"(5 + -3) * 4\" is: [expr (5 + -3) * 4]"
//基本的运算规则
puts "\n................. more examples of differences between \" and \{"
puts {$Z_LABEL [expr $Y + $X]}
puts "$Z_LABEL {[expr $Y + $X]}"
puts "The command to add two numbers is: \[expr \$a + \$b]"
//括号连用的例子
原文:http://www.cnblogs.com/gold-life/p/5731123.html