Monday, May 24, 2010

How do i change binary bit numbers to decimal in C++? ( Mircosoft Visual studio )?

For example,





when i key in 00010001, the result will be equal to 17?








Programmer expert please help!

How do i change binary bit numbers to decimal in C++? ( Mircosoft Visual studio )?
an inefficient, but easy to understand method:


start with a variable 'total' set to 0


as each character is entered, double the 'total' and add the new digit (0 or 1)





to make it interesting, you can even display the running total elsewhere on the screen!


for your example it would display:


0


0


0


1


2


4


8


16


17
Reply:look for the keyword 'ascii' to convert binary to decimal or viceversa
Reply:Use a for loop to calculate xn*2^n-1+x(n-1)*2^(n-2)+.... +x0


Else contact a freelance programmer for helping you doing your project assignment. Check websites like http://getafreelnacer.com/

survey questions

No comments:

Post a Comment