Converting Decimal Numbers from Base 2 to Base 8 or 16Date: 02/20/2009 at 10:49:37 From: James Subject: converting binary with decimal points to hexadecimal and oct My question is about for example 111011001010000.1010101111 and converting it to hex and octal. I can get the 7650 and 73120 respectively for hex and oct for the number to the left of the decimal, but for the right of the decimal point i'm not sure if i add zeroes to the right or left side of my equation. For example, 111 011 001 010 000 equals octal 73120 for the integer. My question is if the right side of the decimal .1010101111 breaks down to 101 010 111 1000 = .5274 or 001 010 101 111= .1257? Date: 02/20/2009 at 20:33:30 From: Doctor Peterson Subject: Re: converting binary with decimal points to hexadecimal and oct Hi, James. Think about WHY we can group binary digits to form octal digits. For integers, it works like this, taking 101011 as an example. This means 1*2^5 + 0*2^4 + 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 If we group these in threes, we get (1*2^5 + 0*2^4 + 1*2^3) + (0*2^2 + 1*2^1 + 1*2^0) = (1*2^2 + 0*2^1 + 1*2^0)*2^3 + (0*2^2 + 1*2^1 + 1*2^0)*2^0 = 5*2^3 + 3*2^0 = 5*8^1 + 3*8^0 (since 8 = 2^3) which is 53 (octal). Now, how about .101011? 1*2^-1 + 0*2^-2 + 1*2^-3 + 0*2^-4 + 1*2^-5 + 1*2^-6 = (1*2^-1 + 0*2^-2 + 1*2^-3) + (0*2^-4 + 1*2^-5 + 1*2^-6) = (1*2^2 + 0*2^1 + 1*2^0)*2^-3 + (0*2^2 + 1*2^1 + 1*2^0)*2^-6 = 5*2^-3 + 3*2^-6 = 5*8^-1 + 3*8^-2 (since 8 = 2^3) which is .53 (octal). So we group starting at the radix point in either direction: 111 011 001 010 000.101 010 111 1... 7 3 1 2 0 . 5 2 7 Incidentally, if you forget this, you can just try a simple number and check your answer. For example, converting 10.1 (binary) to octal, whatever octal value we get has to be equal to 2 1/2 = 2.5 (decimal); the answer that fits this is 010.100 = 2.4 (octal) = 2 4/8. If you have any further questions, feel free to write back. - Doctor Peterson, The Math Forum http://mathforum.org/dr.math/ Date: 02/20/2009 at 23:11:25 From: James Subject: Thank you (converting binary with decimal points to hexadecimal and oct) Just wanted to say thanks and that you were very helpful in clearing up my confusion on the subject. James |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994- The Math Forum at NCTM. All rights reserved.
http://mathforum.org/dr.math/