There is a bug with the comparison operator between two variables of types "int" and "string".
This happens if the string number is two-digit.
Reproduce:
"10" > 9 is false.
9 < "10" is false.
If both are two-digit or both are one-digit it works:
"11" > 10 is true.
10 < "11" is true.
"9" > "8" is true.
"8" < "9" is true.
Bug in Control with Comparison Int/String
- ChristianGoehring
- Posts:14
- Joined: Fri Feb 24, 2017 9:29 am
Bug in Control with Comparison Int/String
- gschijndel
- Posts:376
- Joined: Tue Jan 15, 2019 3:12 pm
Re: Bug in Control with Comparison Int/String
It just seems to me that the int is converted to a string for the comparison, which is not what you expected.
Some say it is good practice to avoid implicit castings to prevent such confusion.
Does it work with an explicit cast to int?
Some say it is good practice to avoid implicit castings to prevent such confusion.
Does it work with an explicit cast to int?