Bit xor of two binary strings and conversion into decimal
Ältere Kommentare anzeigen
Hi, I have two large binary strings (e.g 256 bits each), then how to perform bit Xor operation and then convert the answer into decimal number.
str1='11010011110111110000110110111111';
str2='00011111001101011010001111100001';
str3=bitxor(str1,str2);
%%getting error in str3
3 Kommentare
James Tursa
am 19 Jun. 2020
Bearbeitet: James Tursa
am 19 Jun. 2020
To be clear, you want a decimal number that can't be represented in any native integer type? A 256-bit integer? Or did you just mean you want the result as a vector of 0's and 1's but not character?
lilly lord
am 19 Jun. 2020
James Tursa
am 19 Jun. 2020
See my edited answer.
Akzeptierte Antwort
Weitere Antworten (1)
David Hill
am 19 Jun. 2020
Use java BigInteger
import java.math.*;
a=BigInteger(str1,2);
b=BigInteger(str2,2);
c=a.xor(b);%c will be the decimal BigInteger
1 Kommentar
lilly lord
am 19 Jun. 2020
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!