binary to decimal conversion!!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 2
Reputation: schamb is an unknown quantity at this point 
Solved Threads: 0
schamb schamb is offline Offline
Newbie Poster
 
0
  #1
Oct 12th, 2008
i am writing a binary to decmal conversion program in c++ and am so lost just wondering if anyone out there could lend a hand to a lost soul

also am curious as to how decimal to hexidecimal would work too just wanting to learn more about programming language and am very in experewienced
Last edited by Ancient Dragon; Oct 13th, 2008 at 8:03 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 236
Reputation: TheBeast32 is on a distinguished road 
Solved Threads: 6
TheBeast32's Avatar
TheBeast32 TheBeast32 is offline Offline
Posting Whiz in Training

Re: binary to decimal conversion!!

 
1
  #2
Oct 13th, 2008
I have tried to do this before. Just read a tutorial on how to do it by hand and make a function or whatever.

Check this out: http://www.permadi.com/tutorial/numBinToDec/index.html

Pretty much, you move left starting from the first binary digit on the right. You increment the power from 0, and multiply the digit by 2^power. So:

1010

0*(2^0) = 0
1*(2^1) = 2
0*(2^2) = 0
1*(2^3) = 8

0 + 2 + 0 + 8 = 10

1010 = 10

I'm pretty sure that you can do this conversion for any number base system. Like for base 3: instead of Digit*(2^Power), you would do Digit*(3^Power).
Last edited by TheBeast32; Oct 13th, 2008 at 2:49 am.
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."
--Martin Golding
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 66
Reputation: minigweek is on a distinguished road 
Solved Threads: 4
minigweek's Avatar
minigweek minigweek is offline Offline
Junior Poster in Training

Re: binary to decimal conversion!!

 
0
  #3
Oct 13th, 2008
^^ correct he is , just try to convert the above algorithm into a c++ code and see. Post your code if it fails, and we will further look into it!
I was born Genius, but some loser Leeched it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1000 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC