Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why do these strings compare ?

Status
Not open for further replies.

tcurrier

Programmer
Mar 5, 2000
40
US
Can anyone tell me why this expression turns out 'true' ?

str1 = '1234567891'
str2 = '1234567890'
if str1 = str2 then
say "they're equal"
else
say "they're not equal"

If I compare 2 strings with lengths between 1 and 9, and the last character is different, it's always false. But when I use strings with a length of 10, it turns out true.

Did I miss something somewhere ?
Thanks....
 
Looks like I needed the 'numeric digits' clause.

Using 'numeric digits 10' worked..
 
This operator('=') might take max of 9 digits for comparision. try this operator '=='(Strictly equal) which give you the expected result.

Thanks
Imran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top