Lost Password?

  #1 (permalink)  
Old 01-29-2008, 01:22 AM
stephen0606 stephen0606 is offline
Newbie
 
Join Date: Sep 2007
Posts: 8
Rep Power: 0
stephen0606 is on a distinguished road
Question Code Conversion....

Does c++ gt a special function for conversion between decimal to binary or decimal to hexadecimal and others???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 01-29-2008, 07:00 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 25
Posts: 4,529
Last Blog:
PHP: list()
Rep Power: 50
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Decimal to binary is a simple enough equation that you can create it yourself. Divide your decimal number by 2 and take the remainder. You can do this using the modulus (%) operator. Keep doing this until the decimal number = 0.

Code:
(int) BinaryMod = decimalNumber %2;
(String) BinaryDisplay += BinaryMod;
decimalNumber / 2;
In .NET you can use:

Code:
 Convert.ToString(DecimalValue, 2).PadLeft(8, "0")
Where DecimalValue is your decimal number and 2 is your base. Using that function you can convert to any base.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-31-2008, 01:18 AM
stephen0606 stephen0606 is offline
Newbie
 
Join Date: Sep 2007
Posts: 8
Rep Power: 0
stephen0606 is on a distinguished road
Question

thanks jordan, for decimal and octo i done it edi...but for hexadecimal....i still dunno how to convert d 10,11,12....to alphabet...i just can manage to show their ASCII code...how to do it????
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-31-2008, 07:20 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 25
Posts: 4,529
Last Blog:
PHP: list()
Rep Power: 50
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

You need to convert the base to 16 for hexadecimal. I found some C# code which does this and you should be able to convert it to Manage C++ code very easy: How to convert string to hexadecimal and vice versa
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Code: Simple Encryption Algorithm Void PHP Tutorials 4 04-19-2008 09:52 AM
Basic Calculator AfTriX VB Tutorials 3 02-29-2008 08:53 AM
help with code to play video clip san_001 HTML Programming 2 10-10-2007 02:13 PM
Where to Put PHP Code clookid PHP Tutorials 1 01-11-2007 08:44 PM


All times are GMT -5. The time now is 11:32 PM.

Contest Stats

dargueta ........ 93.00000
John ........ 87.50000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads