| | converting binary to integer
|
| I am reading four digital inputs and I need a way to convert those four bits into a decimal number. Is there an easy way to do it. Thanks. Keith Keith Soldavin kas219@email.psu.edu (URL) (27 years ago, 4-Jun-97, to lugnet.robotics.handyboard)
| | | | Re: converting binary to integer
|
| (...) Multiply each bit by 2^n, where n is the "place" of the number. Then add the products together. For example... 1011 = 1*2^0 + 1*2^1 + 0*2^2 + 1*2^3 = 11 The "zero" place is the one furthest to the right, and you work left from there. ---...--- (...) (27 years ago, 4-Jun-97, to lugnet.robotics.handyboard)
| |