KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have 3 base representations for positive integer numbers: Decimal, in unsigned long variable (e.g. unsigned long int NumDec = 200 ). Hex, in string variable (e.g. string NumHex = "C8" ) Binary, in string variable (e.g. string NumBin = "11001000" ) I want to be able to convert between numbers in all 3 representations in the most efficient way. I.e. to implement the following 6 functions: unsigned long int Binary2Dec(const string & Bin) {} unsigned long int Hex2Dec(const string & Hex) {} string Dec2Hex(unsigned long int Dec) {} string Binary2Hex(const string & Bin) {} string Dec2Binary(unsigned long int Dec) {} string Hex2Binary(const string & Hex) {} What is the most efficient approach for each of them? I can use C and C++, but not boost. Edit: By "efficiency" I mean time efficiency: Shortest execution time.
Tags (comma-separated)
Save Edits
Cancel