Hexadecimal converter.

Hey, I'm thinking of doing a hexadecimal -> decimal/binary converter, binary -> hex/dec and decimal -> binary/hex.

And i'm now at the hexadecimal part, but i feel a bit lost. I'm using double-variables since i want to get the decimal part. But i want to save the (ex. 0.423) part and use it in the next calculation. So for instance:


double num1;

Cout << num1/16 <<"\n";
num2=num1/16;

cout << num2/16 <<"\n";


and so on..

So let's say that num1 is 241.
241/16 = 15.0625
How can you split 15 from 0.0625? Since i wanna use the decimal part for the step 2 in the formula.

I need helpzor!
http://www.cplusplus.com/reference/clibrary/cmath/fmod/

denom / fmod(num, denom) = fracpart

16 / (241 % 16) = 0.0625

Topic archived. No new replies allowed.