how to convert Binary numbers to decimal numbers and decimal numbers to binary

Reply

Join Date: Jan 2009
Posts: 3
Reputation: jhegie is an unknown quantity at this point 
Solved Threads: 0
jhegie's Avatar
jhegie jhegie is offline Offline
Newbie Poster

how to convert Binary numbers to decimal numbers and decimal numbers to binary

 
0
  #1
Feb 9th, 2009
How to convert binary numbers to decimal numbers and decimal numbers to binary numbers?


help!!!!!!
Last edited by Ancient Dragon; Feb 9th, 2009 at 7:56 pm. Reason: deleted color and bold tabs
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 670
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: how to convert Binary numbers to decimal numbers and decimal numbers to binary

 
0
  #2
Feb 9th, 2009
1) Read the rules.
2) Search the forums
3) Show code attempts
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

Re: how to convert Binary numbers to decimal numbers and decimal numbers to binary

 
0
  #3
Feb 9th, 2009
If you're using an int variable for keeping a decimal value and you want to convert it into a binary value, you should know how an int is represented.

An "int" uses 32 bits for representing the number. You can use binary operators in C++ to get the bytes. (OR / AND). I suggest that you do a search on what they are and how to use them. If you don't know the binary representation, do the same.

It's very easy to print all the bytes of an int. You can use a printf option of write a loop that will iterate 32 times to print every byte of the int.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

Re: how to convert Binary numbers to decimal numbers and decimal numbers to binary

 
0
  #4
Feb 9th, 2009
I forgot one thing: you can use >> or << to shift the bits. It can be very useful.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC