Home c++ Translation of Int Number Systems in Int of 2 V 16 -rial

Translation of Int Number Systems in Int of 2 V 16 -rial

Author

Date

Category

And how about a decade in 16-ricke ??


Answer 1, Authority 100%

You never translate into the decimal system.

int a = 10;

Here 10, though it is recorded in the decimal system, but the compiler itself will lead to a convenient system to him (in our case, it is most likely binary).

int x = 0x10;

And here a hexadecimal number is recorded here, but still, it will be recorded in machine-free format.

So, how do you write

int str_mit = str_mat.toint (nullptr, 2);

That translate is not in decimal, but with a binary in a convenient compiler / processor system (and the fact that it is binary, what’s the difference. It could well be a trunk or any other).

And from this form can be translated into any other convenient to display, for example, 16-riche

qstring s = qstring :: number (str_mit, 16);

Note, translate into the string – as the string can store “Display”.

But if it is difficult to understand, then here is a simplified code

qstring n2m (qstring origin, int freom, int to)
{
  int temp = origin.tOnt (nullptr, from);
  Return Qstring :: Number (Temp, To);
}

and respectively 10- & gt; 16

qdebug () & lt; & lt; N2M ("100", 10, 16);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions