mIRC Home    About    Download    Register    News    Help

Print Thread
#38451 26/07/03 06:29 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
when u do
if (1 < a)
so it checks if 1is less then ascii value of 'a' right ?


#38452 26/07/03 06:38 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Yes, it would appear so. I don't see why you couldn't take 30 seconds to test it yourself as I just had to though.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#38453 26/07/03 06:42 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
tested, but it seems that it's not working like that
if (102 < a)
a ascii value is 97, so how 102 can be less then a ? the condition is true but it's not working like i thought ..
do u know ?



#38454 26/07/03 07:45 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
It treats 1, 0, and 2 as alphabetic characters and then compares their ASCII values with the ASCII value of 'a'. So it's comparing 49 (the ASCII value of '1') with 97 first of all, which means that '102' is smaller than 'a', just as 'angel' would be smaller than 'b'.

If you want to numerically compare 102 with the ASCII value of 'a' just use if (102 < $asc(a)).


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#38455 26/07/03 07:58 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
so each comparison is first converted to ascii first? even when they both numbers ? i mean that if (1 < 2) will make it if (49 < 50) ?

#38456 26/07/03 08:02 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
No. Only when one of the operands is not a number.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#38457 26/07/03 08:05 PM
Joined: Dec 2002
Posts: 109
T
Vogon poet
Offline
Vogon poet
T
Joined: Dec 2002
Posts: 109
Quote:
so each comparison is first converted to ascii first? even when they both numbers ? i mean that if (1 < 2) will make it if (49 < 50) ?


No, only when mIRC finds itself running mathematical comparisons where one or more of the comparitive elements is non-numeric. (a < b) is meaningless in mathematical terms, but mIRC gets clever and compares the ASCII values. Because ($asc(a) < $asc(b)) is true, it can detect that "a" comes before "b" which is an "added feature" of the if-else comparison function in mIRC.

But, as we have seen in this thread, it can lead to complications where the other element is actually a number value.. because the other one is still non-numeric, it carries on converting both elements to their first ascii value. it's confusing, but does work as it's supposed to.

NOTE: only the first character in each element will count, because only one comparison can be made, and hence only one ASCII value taken into consideration. Remember, $asc(a) == $asc(ab).


<Ingo> I can't uninstall it, there seems to be some kind of "Uninstall Shield"
#38458 26/07/03 08:15 PM
Joined: May 2003
Posts: 730
S
ScatMan Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
ok thx

#38459 27/07/03 01:36 PM
Joined: Dec 2002
Posts: 117
R
Vogon poet
Offline
Vogon poet
R
Joined: Dec 2002
Posts: 117
Quote:

NOTE: only the first character in each element will count, because only one comparison can be made, and hence only one ASCII value taken into consideration. Remember, $asc(a) == $asc(ab).


That's not true, if the first two ascii values are the same, the next two are compared, then the third, etc:
$iif(ab > aa,$true,$false) = $true

If two strings aren't of equal length, but the start of the longest is the same as the shortest, the longer string will be 'larger':
$iif(aa > a,$true,$false) = $true

Ofcourse, if you use $asc() yourself only the first character counts, because $asc only returns a numerical value for the first character and then the comparison is made:
$iif($asc(aa) > $asc(a),$true,$false)
is first converted to
$iif(97 > 97,$true,$false)
and then the comparison is made, resulting in $false


$input(Me like stars, You too?)
#38460 27/07/03 04:18 PM
Joined: Dec 2002
Posts: 109
T
Vogon poet
Offline
Vogon poet
T
Joined: Dec 2002
Posts: 109
Quote:
That's not true, if the first two ascii values are the same, the next two are compared, then the third, etc:
$iif(ab > aa,$true,$false) = $true


I stand corrected.
This must be an extension of the aforementioned feature, as in alphabetical terms, ab is indeed greater than aa. Eg. take a look at your Excel spreadsheets and scroll down. The columns go

A B C D E F G H I J K L M N O PQ R S T U V W X Y Z AA AB AC AD AE etc..

So mIRC's alphabetical comparison system is even more complex than I thought. wink


<Ingo> I can't uninstall it, there seems to be some kind of "Uninstall Shield"

Link Copied to Clipboard