Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coverting Decimal to 32-bit Binary

Status
Not open for further replies.

rache1

Programmer
Mar 20, 2001
9
TW
Hi.

Help! I have beem having problems in converting from Decimal to 32 bit binary, e.g: how to I convert 4,000,000 decimal to a 32 bit binary??

Thanks for the help!
 
I was thinking maybe you can try doing bit shifting and testing to print out the number in binary.

For example:

displayMask = 1 << 31;
/* Place your decimal in value */
value;

for (c = 1; c <= 32; c++) {
putc((displayMask & value) ? '1' : '0');
value <<= 1;
}

I know I have done this in C. But this is really very easy to convert into assembly language. I can do this for you. But that would steal the joy of solving your own problems from you. If you really cannot, post another message and I will try to convert it into assembly for you.

HTH,
David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top