Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Dec 3rd, 2004, 9:22 AM   #1
RosdaHale
Newbie
 
Join Date: Nov 2004
Posts: 15
Rep Power: 0 RosdaHale is on a distinguished road
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!)
RosdaHale is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC