I want to write a program , that shows numerical systems in "10" in "8" , "16" , "2" systems , I've done in "10" so far and I'm confused how to do in other systems.
You can use the flags dec, hex and oct to convert them automatically to Decimal, Hexadecimal and Octal.
For binary you have to build your one function to convert it.
Here is an example how dec, hex and oct works:
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
#include <iomanip>
usingnamespace std;
int main(){
int num = 145;
cout << "oct: " << oct << num << '\n';
cout << "dec: " << dec << num << '\n'; //If you change the flag to oct or hex you must
// put it back to dec to show decimal again...
cout << "hex: " << hex << num << '\n';
}
Thanks for that Mitsakos, I didn't know that. There was an example in a book a was reading that converted numbers over but used modulus and then left or right shift or something. I thought it was a bit more complicated then that. Cool.