I have two absurdly long binary Variables a and b with the assumption that they have the same length. What I want is simple: XOR them and store in a new variable, that's it. As I got fed up with different errors like Expression.Convert: Object of type 'System.Int64' cannot be converted to type 'System.Int32' or Value was either too large or too small for a UInt32 or Arithmetic overflow error converting expression to data type int, I will do it on my own.
- Iterate bit by bit (char by char) through the aandb.
- XOR bit of awith bit ofbonpos iand concatenate this newly created XORed bit to a new variablenewXorVar
Here's my code:
@echo off 
setLocal enableDelayedExpansion
set a=01101000011001010110010101000010101010101010101010111010101010101010101010100000000001101111000010101010101101100011011000110111111010101000001
set b=01110111011011110111001001101100011001000010000111011000110010101100101010000101010101010101100011011000110110001100100001010110110001101100011
set pos=0
set newXorVar=""
:NextChar
  ::check if each character can be reached --> okay
  echo Char %pos% is !a:~%pos%,1! and !b:~%pos%,1! 
  ::XOR each bit --> does not work
  set /a xorAB=!a:~%pos%,1!^!b:~%pos%,1!
  ::echo does not work --> not the desired output
  echo !xorAB! 
  newXorVar=!newXorVar!!xorAB!
  set /a pos=pos+1
  if "!a:~%pos%,1!" NEQ "" goto NextChar
::output computed newXOR var
echo !newXorVar!
Can anybody help me out fixing my code so that it works?
 
     
    