You want to round [lindex $all 3], so
Code: Select all
set num [lindex $all 3]
set num [expr round(100*$num)/100.0]
if {$num >= 0} {
set num "+$num"
}
ps. just a stylistic note, it's usually a lot clearer to break things onto multiple lines than have one line with 4 levels of nested brackets hehe.
pps. place this code before your "string map" command and then use $num instead of [lindex $all 3]. Also, "string map" is a strange way to do it. It's better to say if $num < 0, set num "<colorcode>$num" and the other color in the else.