I was trying to do some data validation, and ran across the following situation, which the example below demonstrates.
% info patchlevel
8.4.17
% set s "5\n"
5
% string is double -strict $s
1
% expr {$s >= 0.0}
1
The string 's' is clearly not a double since it contains a control character, however the string test for double is returning true, which it should fail. The expr command is even more puzzling since the string is not a number, but the comparison returns true.
IMHO both of these tests should return zero as the string is clearly not a double.
Logged In: YES
user_id=72656
Originator: NO
To be clear, this control char is actually in the subspace of whitespace characters, which have more lenient handling at the C level. It is no different than " 5 ", which is 5 as a number to strtod.
BTW, the comparison <= is dangerous because it can do string comparisons, but you will see that it is a valid "integer" by doing + 1 as well.