mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 208
H
Hrung Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
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.

Last edited by Hrung; 28/07/05 10:53 PM.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
If the number is beyond mIRC's number size limit, the string should be treated as text, yes.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
In the meantime, and assuming the compared strings aren't going to have wildcard characters, iswm is a short alternative.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.


Link Copied to Clipboard