11-04-2008
57,
0
Join Date: Aug 2005
Last Activity: 21 May 2010, 6:01 AM EDT
Posts: 57
Thanks Given: 0
Thanked 0 Times in 0 Posts
Interesting TCL behavior: 007 == 7 is true; 008==8 is false.
Hi all,
If anyone has the explanation for the following issue, please share it with me.
I am comparing two variable a and b with the values of 007 and 7, for these values it get evaluated as True. For a=008 and b=8, for these values it get evaluated as false.
#!/bin/tclsh
set a 007
set b 7
if { $a == $b } {
puts "$a equals to $b"
} else {
puts "$a not equals to $b"
}
set a 008
set b 8
if { $a == $b } {
puts "$a equals to $b"
} else {
puts "$a not equals to $b"
}
Output:
007 equals to 7
008 not equals to 8
In Fact a = (001,002,...007) and b= (1,2,...7) it get evaluated as True and becomes false for a > 007 and b > 7.
Thanks
Sarwan