mIRC Homepage
It would be handy when needing to do multiple bitwise operations to have an identifier capable of doing these based on the standard C++ bitwise operators syntax: &, |,^ ,~, <<, >>

which is and, or, xor, not, shift-left, shift-right.

Currently there are no bitwise operations in mIRC for bit-shifting.

I've whipped up an example identifier:
Code:
bitwise { 
  var %pattern = /^(\d+)([\x26\x7C\x5E\x7E]|<<|>>)(\d+)/
  while ($regex($1,%pattern)) { tokenize 32 $regsubex($1,%pattern,$iif($len(\2) > 1,$calc(\1 $iif(\2 = >>,//,*) 2 ^ \3),$eval($+($,$gettok(and or xor not,$pos(&|^~,\2,1),32),(\1,\3)),2))) }
  return $1
}


this greatly reduces multiple bitwise tasks and makes for cleaner easier to follow conditions rather than something like $and($or($xor($not())))

The hard way, Example:
//echo -a $and($base(1 $+ $str(0,3),2,10),7)

Output:
0

VS-

The easy way, Example:
//echo -a $bitwise(1<<3&7)

Output:
0

The only issue i see is trying to support spacing between bitwise operations since | is already a special character implying a new line which would break things. as long as there is no spaces between, so you do like "x|x" there's no issue, or $+(x,|,x), etc... or maybe even replace bitwise inclusive or with another character.

Also it should be known that there's no wrap for bitshifting, since there is no way to create types like uint8 or something when bitshifting out-of scope for such a type.

It would also be nice to have compound assignment operators for variables, such as: +=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=

Examples:
%x += 3
%y *= 2

but I guess that should be another feature thread of it's own.
I support this. Beat me to posting.

Would be better in an optimized rewrite of $calc() smile
Great idea +1
© mIRC Discussion Forums