mIRC Homepage
Posted By: Hrung change === behavior with numbers - 28/07/05 10:31 PM
So, I was messing around with some script, and I discovered that...

if (123456789123456789123456789123 == 123456789123456789123456789122) echo -a true

echoes true, even though they are not the same number (check the last digit). Now, I can understand that, since mirc has to treat them as numbers for comparisons like (0.1 == .1) to work, and as most any language does, mirc has limits to the size of number it can handle, so that's fine. My suggestion is that === should, in addition to being case-sensitive for text, treat numbers as text as well, so that

if (123456789123456789123456789123 === 123456789123456789123456789122) echo -a true

does nothing, since the two strings are not exactly the same.

Questions? Comments? Abuse?

edit: also, in case it was not clear, (0.1 === .1) would be false with this change.
Posted By: argv0 Re: change === behavior with numbers - 28/07/05 10:34 PM
If the number is beyond mIRC's number size limit, the string should be treated as text, yes.
Posted By: qwerty Re: change === behavior with numbers - 28/07/05 11:30 PM
In the meantime, and assuming the compared strings aren't going to have wildcard characters, iswm is a short alternative.
Posted By: DaveC Re: change === behavior with numbers - 30/07/05 12:35 PM
a simple patch that i have done when encountering this problem was this

if (x %var1 === x %var2)

so you get

if (x 123456789123456789123456789123 === x 123456789123456789123456789122) echo -a true

* simply stops being a number
Posted By: argv0 Re: change === behavior with numbers - 30/07/05 06:14 PM
well that defeats the purpose of a number comparison then, so if your input is a valid number, it might again not work

var %input = .1 | if (%input == 0.1) echo -a $true

vs.

var %input = .1 | if (x %input == x 0.1) echo -a $true

the second will not fire
Posted By: DaveC Re: change === behavior with numbers - 31/07/05 03:03 AM
And its not ment to fire becuase THAT is exactly what Hrung asked for. A textual based Casesensitive match/mismatch, the fact its a valid number only in the text is unimportant.
© mIRC Discussion Forums