Download presentation
Presentation is loading. Please wait.
1
168493 XML and Web Services (II/2546)
Base 2 to Base 10 Let b be a digit in the number of base 2 Then for a number of base 2, B, that has n digits, we can write them as B = bn-1bn-2..b2b1b0 The total value of B in a decimal number, D, is D = (bn-1x2n-1) + (bn-2x 2n-2) + … + (b2x22) + (b1x21) + (b0x20) 178110: Computer Programming (II/2546) Dept. of Computer Engineering, Khon Kaen U.
2
178110: Computer Programming (II/2546)
Examples: Base 2 Base 10 1 = 1x20 = 1 10 = 1x21 + 0x20 = 2 101 = 1x22 + 0x21 + 1x20 = = 5 = 1x24 + 1x23 + 0x22 + 0x x20 = = 25 = 1x25 + 1x24 + 1x23 + 1x x21 + 1x20 = = 63 178110: Computer Programming (II/2546)
3
178110: Computer Programming (II/2546)
Base 10 to Base 2 D = (bn-1x2n-1) + (bn-2x 2n-2) + … + (b2x22) + (b1x21) + (b0x20) Procedure: Keep dividing D with 2 until the number is less than 2 The answer is the concatenation of final quotient and all remainders 178110: Computer Programming (II/2546)
4
178110: Computer Programming (II/2546)
Examples: Base 10 Base 2 13 = 11012 178110: Computer Programming (II/2546)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.