Originally Posted by
aurora
And i wanted to know is there any standard function to perform BITWISE AND operation on such two 'strings of digits'??
No. You appear to be very confused. You do not need a binary string representation of the input hex digits if what you want to do is a bitwise operation between two of them.
This is a hexadecimal representation of a pair of numbers:
"123B"
"456F"
"123B"
"456F"
To copy to clipboard, switch view to plain text mode
and the corresponding binary representation of the same numbers:
"0001001000111011"
"0100010101101111"
"0001001000111011"
"0100010101101111"
To copy to clipboard, switch view to plain text mode
Note that neither of those things is actually a number from the perspective of doing any sort of mathematics. They are all string literals, i.e. a list of characters.
These are the integer values that those strings represent:
int i = 4667; // alternatively int i = 0x123b;
int j = 17775; // alternativley int j = 0x456f;
int i = 4667; // alternatively int i = 0x123b;
int j = 17775; // alternativley int j = 0x456f;
To copy to clipboard, switch view to plain text mode
and the bitwise and:
int and = i & j;
// and == 43;
int and = i & j;
// and == 43;
To copy to clipboard, switch view to plain text mode
which can be expressed in hexadecimal or binary strings as:
"2B"
"101011"
"2B"
"101011"
To copy to clipboard, switch view to plain text mode
To go from string to integer use QString::toInt(), and from integer to hex or binary use QString::number().
Bookmarks