Quadratic equation in Tcl

Example for versions ActiveTcl 8.5, JTcl 2.1.0, Tcl 8.4, Tcl 8.5.7
set A [gets stdin]
if {$A==0} { 
    puts "Not a quadratic equation."; 
    return 
}
set B [gets stdin]
set C [gets stdin]
set D [expr {$B*$B-4*$A*$C}]
set r [expr {-0.5*$B/$A}]
set i [expr {0.5*sqrt(abs($D))/$A}]
if {$D==0} {
    puts "x = $r"
} elseif {$D>0} {
    puts "x1 = [expr {$r+$i}]"
    puts "x2 = [expr {$r-$i}]"
} else {
    puts "x1 = ($r, $i)"
    puts "x2 = ($r, [expr {-$i}])"
}