943,186 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3474
  • C++ RSS
Feb 9th, 2009
0

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

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jhegie is offline Offline
3 posts
since Jan 2009
Feb 9th, 2009
0

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

1) Read the rules.
2) Search the forums
3) Show code attempts
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008
Feb 9th, 2009
0

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

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.
Reputation Points: 72
Solved Threads: 26
Posting Whiz in Training
GDICommander is offline Offline
209 posts
since Jun 2008
Feb 9th, 2009
0

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

I forgot one thing: you can use >> or << to shift the bits. It can be very useful.
Reputation Points: 72
Solved Threads: 26
Posting Whiz in Training
GDICommander is offline Offline
209 posts
since Jun 2008
Feb 28th, 2010
-3
Re: how to convert Binary numbers to decimal numbers and decimal numbers to binary
Reputation Points: 4
Solved Threads: 0
Newbie Poster
aplantia is offline Offline
1 posts
since Feb 2010
Mar 1st, 2010
0
Re: how to convert Binary numbers to decimal numbers and decimal numbers to binary
There is also the Windows calculator who can do decimal-to-binary and binary-to-decimal transformations. It might be useful if you want to validate what you do in code.
Reputation Points: 72
Solved Threads: 26
Posting Whiz in Training
GDICommander is offline Offline
209 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Call cmd.exe on C++ program
Next Thread in C++ Forum Timeline: in main, try to understand





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC