Forum Discussion
Altera_Forum
Honored Contributor
18 years agoTo do calculations you have to use the expr command within square brackets:
set a 2.0 set b 3.0 set c [expr $a + $b] So expr calculates the value, and the square brackets mean execute the commands inside and use their returned value. Finally, I recommend using decimals for all numbers. In Tcl, integer types are handled differently than decimals, so: expr 5 / 2 will return 2, not 2.5. (Dumb, I know, but it's part of the Tcl language...)