Bitwise operations on string representation of a binary number

binary, bit-manipulation, qt

Solution

This should work:

QString a = "001";
QString b = "010";
QString c = "100";

QString d = QString::number(a.toInt(0, 2) | b.toInt(0, 2) | c.toInt(0, 2), 2);

It does what Alex Farber said. Converts the strings to integers, does the operation and then converts the result back to a string.

Problem

What is the simplest solution to get a bit wise operation on a string representation of a binary number? Example ``` QString a = "001"; QString b = "010"; QString c = "100"; // QString d = a | b | c -> d = "111" ```

Original source