From Newsgroup: comp.lang.tcl
On 9/17/2025 10:19 AM, meshparts wrote:
I just realized, that
lsearch -real -index 0 {0 1.0} 1.00
does not find the 1.0 element in the given list!
Same for:
lsearch -real -index 0 {0 1.0} 1
Why is that???
Since "expr 1.0==1.00" and "expr 1.0==1" return true, I realy wonder...
Any explanation for this behavior?
Interesting. Tcl 8.6 gives the expected results, or so it seems at first:
% lsearch -real -index 0 {0 1.0} 1.0
1
Bu then look at these:
% lsearch -real -index 0 {0 1.0} 1.00
-1
% lsearch -real -index 0 {0 1.0} 1.000
-1
Convert your pattern to a real number doesn't seem to really help either:
% lsearch -real -index 0 {0 1.0} [expr 1.000]
1
% lsearch -real -index 0 {0 1.00} [expr 1.000]
-1
--- Synchronet 3.21a-Linux NewsLink 1.2