Download presentation
Presentation is loading. Please wait.
Published byPercival Sparks Modified over 9 years ago
1
Converting Numbers Between Bases
2
While the quotient is not zero… Divide the decimal number by the new base. Make the remainder the next digit to the left in the answer. Replace the original dividend with the quotient. Converting Decimal to Other Bases
3
Converting Decimal to Binary Dim quotient, bDigit As Integer Dim bString As String quotient = ‘number to be converted bDigit = 0 bString = VbNullString
4
Do While quotient not = 0 bDigit = quotient Mod 2 bString = CStr(bDigit) & bString quotient = quotient \ 2 Loop Converting Decimal to Binary
5
Converting Binary to Decimal Multiply the bit in each position by the power of 2 in that position, and Sum the products.
6
Converting Binary to Decimal Dim bLen, number, c As Integer Dim bString As String bString = ‘the binary string to convert bLen = bString.Length-1
7
Converting Binary to Decimal For c = 0 To bLen number = number + _ Val(bString(c)) * 2 ^ (bLen – c) Next
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.