| | |
binary to decimal conversion!!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 2
Reputation:
Solved Threads: 0
0
#1 Oct 12th, 2008
i am writing a binary to decmal conversion program in c++ and am so lost just wondering if anyone out there could lend a hand to a lost soul
also am curious as to how decimal to hexidecimal would work too just wanting to learn more about programming language and am very in experewienced
also am curious as to how decimal to hexidecimal would work too just wanting to learn more about programming language and am very in experewienced
Last edited by Ancient Dragon; Oct 13th, 2008 at 8:03 am.
I have tried to do this before. Just read a tutorial on how to do it by hand and make a function or whatever.
Check this out: http://www.permadi.com/tutorial/numBinToDec/index.html
Pretty much, you move left starting from the first binary digit on the right. You increment the power from 0, and multiply the digit by 2^power. So:
1010
0*(2^0) = 0
1*(2^1) = 2
0*(2^2) = 0
1*(2^3) = 8
0 + 2 + 0 + 8 = 10
1010 = 10
I'm pretty sure that you can do this conversion for any number base system. Like for base 3: instead of Digit*(2^Power), you would do Digit*(3^Power).
Check this out: http://www.permadi.com/tutorial/numBinToDec/index.html
Pretty much, you move left starting from the first binary digit on the right. You increment the power from 0, and multiply the digit by 2^power. So:
1010
0*(2^0) = 0
1*(2^1) = 2
0*(2^2) = 0
1*(2^3) = 8
0 + 2 + 0 + 8 = 10
1010 = 10
I'm pretty sure that you can do this conversion for any number base system. Like for base 3: instead of Digit*(2^Power), you would do Digit*(3^Power).
Last edited by TheBeast32; Oct 13th, 2008 at 2:49 am.
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."
--Martin Golding
--Martin Golding
![]() |
Similar Threads
- Binary to decimal (Java)
- Conversion (VB.NET)
- Binary Fraction conversion question (C)
- Number System:Conversion from binary to decimal (C)
- Stack conversion (C++)
- binary to decimal values conversion (C)
- i need code for binary to decimal (it should be written in 'C') (C)
Other Threads in the C++ Forum
- Previous Thread: help!! really need this!!
- Next Thread: While loop error
Views: 1000 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory multidimensional newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





