Hello,
I'm learning C++, then i want to know how i can do a convertion of an decimal number to an hexamal number, i know the calculation form to do this, but the thing that i don't know is how i can represent the remain in the formula. Here is an example of a convertion of the number 42(in decimal to hexamal):

42 : 16 = 2
Remain 10.
10 in hexamal is A.
Then 42 in hexamal is 2A

How i can do a program that knows what is tha remain, this is my question?

Thanks,
Nathan Paulino Campos

Pick 1)

I)

std::cout<<hex;

II)

hex(cout);

III)

cout.setf(ios_base::hex,ios_base::basefield);

All these shows the output in hex. So no calculation needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.