Hello,
I am working in a program and I need to convert a integer to a binary number, and then do different stuff depending on the binary values of that number. My question is, how can I access to the individual characters of a QString binary representation of a number?
My code goes something like this:
Having:
int mynumber;
int mynumber;
To copy to clipboard, switch view to plain text mode
I convert that int to binary using:
QString mybinary(QString::number(mynumber, 2));
To copy to clipboard, switch view to plain text mode
Now, how to know the value of each QString character? to do something like this:
if(mybinary[1]==0) other_variable=x;
if(mybinary[1]==0) other_variable=x;
To copy to clipboard, switch view to plain text mode
Can I do even mathematics operations such as?:
mybinary[0]*other_variable/Pi;
mybinary[0]*other_variable/Pi;
To copy to clipboard, switch view to plain text mode
I hope you can understand what I mean.
Thank you very much!
Bookmarks