![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Nov 2004
Posts: 15
Rep Power: 0
![]() |
Please help I am having a nightmare with this.
I need to convert a decimal number in to Hex and binary. Dec_Num is a random integer number up to 255. Then I have Bin_Num (integer) and Hex_Num (Char - as letters are needed). I have the following. Bin_Num =Convert_to_Dec(Dec_Num) Hex_Num =Convert_to_Hex(Dec_Num) Functions : int Convert_to_Dec (int a) { Return(Result); } int (Convert_to_Hex (char a) { Resturn(Result); } Now heres my problem I have tried so many ways and cant get anyting to work. To work out binary you simply divide by 2 and store the remainder, so I set up an array to store remainder. But my returned result NEEDS to be a integer, so I converted to an integer, but the result is still always wrong. Also Hex basiaclly the same, but obviously need to return a char result as it will contain letters. NOTE : I AM NOT ALLOWED TO USE ANY EXSISTING C++ COMMANDS TO WORK OUT THE DEC AND HEX, I MUST WRITE MY OWN FUNCTION TO DO IT. PLEASE SOMEONE HELP !! PLUS : The returned results must be integer and char (basiaccly anything apart from ARRAY!) |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|