You can do this by getting the log base 10 of the number. [expr log10($number)]

You can get the regexp of the number, and then get the string length of the digits to the right and left of the decimal point.

In my case, I had a variable called precision, which determined how many places beyond the decimal point were displayed.

So, for precision = 2, .007 would be displayed as .01

To determine if this rounding was occuring:

set non_rounded_number $my_value
set rounding_p [expr (-1 * log10($non_rounded_number)) > $precision]
if {$rounding_p} {
# we have rounding
}

Lars H: I'm not sure who wrote the above, or what the code would be useful for, but I suspect the casual user who is having a problem with something similar would be better off reading about

format (the %e, %f, and %g specifiers in particular) and

A real problem.