Anonymous user
Arithmetic/Integer: Difference between revisions
m
→{{header|Tcl}}
m (→{{header|Tcl}}: comment about using braces in expr command) |
m (→{{header|Tcl}}) |
||
Line 616:
=={{header|Tcl}}==
▲ puts "Please enter two numbers:"
gets stdin x
Line 628 ⟶ 627:
$x / $y = [expr {int($x / $y)}]
$x mod $y = [expr {$x % $y}]
"</lang>
Since Tcl doesn't really know about the "type" of a variable, the "<tt>expr</tt>" command is used to declare whatever follows as an "expression". This means there is no such thing as "integer arithmetic" and hence the kludge <tt>int( $x / $y )</tt>.
|