{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

More_Number_Rep

# More_Number_Rep - Binary Number System Base 10 digits 0 1...

This preview shows pages 1–4. Sign up to view the full content.

Computer Science Dept Va Tech August, 1999 ©1995-1999 Barnette ND, McQuain WD, Keenan MA 1 15. Binary Numbers Programming in C++ Binary Number System Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1 + 7 * 10 0 Similarly, in base 2, the digits of a number are just coefficients of powers of the base (2): 1011 = 1 * 2 3 + 0 * 2 2 + 1 * 2 1 + 1 * 2 0 Any real number can be represented in any base; humans generally use base 10, but computer hardware generally uses base 2 representation.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Computer Science Dept Va Tech August, 1999 ©1995-1999 Barnette ND, McQuain WD, Keenan MA 2 15. Binary Numbers Programming in C++ Converting from Base 10 to Base 2 The base 10 system is also known as the decimal system; base 2 is referred to as binary. How can we convert an integer from decimal to binary? Here is a simple algorithm: While N > 0 Do Write N % 2 // remainder when N is divided by 2 N <-- N / 2 // divide N by 2 Endwhile Note that the remainder will always be either 0 or 1, a binary digit or bit . The resulting sequence of bits is the binary representation of the integer N. See the next slide for an example...
Computer Science Dept Va Tech August, 1999 ©1995-1999 Barnette ND, McQuain WD, Keenan MA 3 15. Binary Numbers

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

More_Number_Rep - Binary Number System Base 10 digits 0 1...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online