mIRC Home    About    Download    Register    News    Help

Print Thread
#28500 07/06/03 12:27 AM
Joined: Jun 2003
Posts: 3
M
MijT Offline OP
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Jun 2003
Posts: 3
Why $not doesn't return the binary?
ie:
//echo -a $not(1) return: 4294967294
and not 0

//echo -a $not(100) return: 4294967195
and not 011

I need it to make C1 and C2 to make subs in binary like add.

#28501 07/06/03 01:41 AM
Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
alias binnot return $right($base($not($base($1,2,10)),10,2),$len($1))


Code:
//if ( khaled isgod ) echo yes | else echo no
#28502 07/06/03 01:53 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This is not a bug. $not() (as well as $or(), $and() etc) accepts decimal values, not binary. You need to use $base() to convert 110 to decimal and then use it as input to $not(). Also note that a number that's to be NOT'd is considered 32-bit. For example, 5 in binary is:
00000000000000000000000000000101
$not(5) is 4294967290, which, in binary, is:
11111111111111111111111111111010
by comparing the above two binary numbers, it's easy to conclude that $not() works as expected.

If I understood what you want to do, it's easy to make an alias for this:
Code:
alias notreally return $base($xor($base($1,2,10),$calc(2^ $len($1) -1)),10,2,$len($1))


Edit: looks like I was a bit late. While I was previewing my post, theRat sneaked in with a very clever solution that does the same thing.

Last edited by qwerty; 07/06/03 02:03 AM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#28503 07/06/03 02:00 AM
Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
since $not returns a NOT in a 32bit so when u are doing $not(Num) it first convert the Num to binary and then make it 32bit
for example
$not(2)
binary of 2 is 10 ( $base(2,10,2) )
then make it 32 bit (32 digits)
it's 00000000000000000000000000000010 ( $base(10,10,10,32) )
then compare NOT in each digit (0 NOT = 1, 1 NOT = 0)
it will be
11111111111111111111111111111101
the decimal of this number is 4294967293 ( $base(11111111111111111111111111111101,2,10) )
that's how $not works..


#28504 08/06/03 06:28 AM
Joined: Jun 2003
Posts: 3
M
MijT Offline OP
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Jun 2003
Posts: 3
I understand, thankz smirk


Link Copied to Clipboard