0

How to convert binary numbers to decimal numbers and decimal numbers to binary numbers?


help!!!!!!

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by GDICommander
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.