Warcraft III resources & community, 2003–2006 · archived

BitwiseXor

not rated
Submitted by Aiursrage2kVariable Change0 downloads
Performs an bitwise xor. Requires the CountBits function.

Source

function BitwiseXor takes integer val1, integer val2 returns integer
  local integer i = 0
  local integer retval  = 0
  local integer max = CountBits(IMaxBJ(val1, val2))

  loop
    exitwhen i > max
    if ModuloInteger(val1, 2) != ModuloInteger(val2, 2)  then
        set retval = retval + R2I(Pow(2,i))
    endif
    set val1 = val1 / 2
    set val2 = val2 / 2
    set i = i + 1
  endloop
  return retval
endfunction

Comments

0

No comments.