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:

Qt Code:
  1. int mynumber;
To copy to clipboard, switch view to plain text mode 

I convert that int to binary using:

Qt Code:
  1. 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:

Qt Code:
  1. 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?:

Qt Code:
  1. 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!