Binary to hex conversion proof

  • Context: Undergrad 
  • Thread starter Thread starter njama
  • Start date Start date
  • Tags Tags
    Binary Proof
Click For Summary

Discussion Overview

The discussion centers around the validity of converting binary numbers to hexadecimal format, exploring the mathematical proof and reasoning behind this conversion process. Participants provide examples, breakdowns of binary quartets, and various approaches to formalizing the proof.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant presents an example of a binary number and breaks it into quartets to demonstrate the conversion to hexadecimal.
  • Another participant suggests that the conversion can be understood by factoring out multiples of 16 from the binary representation.
  • A different participant proposes a method of proving the conversion by considering the number of digits and their arrangement in quartets.
  • Some participants discuss the need for clarity in notation, particularly regarding powers of 16 and their relation to the binary digits.
  • One participant emphasizes that leading zeros can be added to binary numbers without changing their value, which aids in making the number of bits divisible by four.
  • Another participant suggests using a formula involving the total number of bits to express the conversion more clearly.

Areas of Agreement / Disagreement

Participants express various methods and perspectives on proving the conversion, indicating that there is no consensus on a single approach or proof structure. Multiple competing views remain on how best to articulate the conversion process.

Contextual Notes

Some participants note the importance of clearly defining terms and maintaining consistency in notation, particularly when dealing with powers of 2 and 16. There are unresolved mathematical steps and assumptions regarding the treatment of leading zeros and the arrangement of binary digits.

Who May Find This Useful

This discussion may be useful for those interested in number theory, digital systems, or anyone looking to understand the mathematical foundations of binary to hexadecimal conversion.

njama
Messages
215
Reaction score
1
Hello PF members!

I am interested in proving that the conversion of binary to hex is valid.

Example: 1000100100110111

Breaking into 'quartets' 1000 1001 0011 0111

Now using the fact that 24 = 0...15

1000 = 8, 1001 = 9, 0011 = 3, 0111 = 7. So

10001001001101112=893716

I can create the table starting from 0000 to 1111. I need to prove that this conversion really works.

I would start the proof by stating that the number in binary form is:

[tex]b_1b_2...b_{n-1}b_n[/tex]

If n mod 4 == 0 (if the remainder of the division of n with 4 is zero) then:

[tex]b_1b_2b_3b_4 ... ... ... b_{n-3}b_{n-2}b_{n-1}b_n[/tex]

But how to prove afterward?

else we can add m zeroes so that (m+n) mod 4 ==0.

By adding zeroes before the binary number I can easily prove that nothing is changed.

[tex](*)=b_1b_2...b_{n-1}b_n=b_n*2^0 + b_{n-1}*2^1+...+b_2*2^{n-2}+b_1*2^{n-1}[/tex]

[tex]00..00b_1b_2...b_{n-1}b_n=b_n*2^0 + b_{n-1}*2^1+...+b_2*2^{n-2}+b_1*2^{n-1}+0*2^n+0*2^{n+1}...+0*2^{n+m}=(*)[/tex]

Any help would be appreciated.
 
Mathematics news on Phys.org
This is not a proof but an example to show how you might think of it (I reversed the numbering of the coefficients in your example, to match the exponents):

A 12-digit binary number: [tex]b_{11}2^{11}+b_{10}2^{10}+b_{9}2^{9}+b_{8}2^{8}+b_{7}2^{7}+b_{6}2^{6}+b_{5}2^{5}+b_{4}2^{4}+b_{3}2^{3}+b_{2}2^{2}+b_{1}2^{1}+b_{0}2^{0}[/tex]

Factor out multiples of 16: [tex]2^8(b_{11}2^{3}+b_{10}2^{2}+b_{9}2^{1}+b_{8}2^{0})+2^4(b_{7}2^{3}+b_{6}2^{2}+b_{5}2^{1}+b_{4}2^{0})+2^0(b_{3}2^{3}+b_{2}2^{2}+b_{1}2^{1}+b_{0}2^{0})[/tex]

Rewrite with powers of 16: [tex]16^2(b_{11}2^{3}+b_{10}2^{2}+b_{9}2^{1}+b_{8}2^{0})+16^1(b_{7}2^{3}+b_{6}2^{2}+b_{5}2^{1}+b_{4}2^{0})+16^0(b_{3}2^{3}+b_{2}2^{2}+b_{1}2^{1}+b_{0}2^{0})[/tex]

Everything in parentheses is a hex digit, with value 0-15.
 
Ohh... Thanks a lot.

Here is what I've done:

(I've excluded the case which I have already proof with the zeroes before the number)

So let's suppose there are m+n+1 digits, and we can form a quartets.

The binary number is:

[tex]b_{m+n}2^{m+n} + b_{m+n-1}2^{m+n-1} + ... + b_32^3+b_22^2+b_12^1+b_02^0[/tex]

Now factoring out multiples of 16

[tex]2^{m+n-3}(b_{m+n}2^3+b_{m+n-1}2^2+...+b_{m+n-3}2^0)+...+2^0(b_32^3+b_22^2+b_12^1+b_02^0)[/tex]

There are m+n / 4 hexadecimal digits. Did I do the proof correctly ? (except for minor mistakes)
 
That looks pretty good, except I think you need to make it clear that the terms are powers of 16. That will make the notation cumbersome though. For example, [tex]2^{m+n-3}[/tex] would be [tex](2^{4})^{(m+n+1)/4 - 1}[/tex]. Not too pretty, but a cleaner way doesn't come to mind at the moment.
 
Try thinking about it this way:

Each more significant binary digit is represented by a 0 or 1 multiplied by a power of 2 that is greater than the previous digit by 1. In other words (sticking with whole numbers), the lowest binary digit can be represented by [tex]b_02^0[/tex]

Remembering, of course that [tex]b_n=0[/tex] or [tex]b_n=1[/tex] for all n.

The next more significant binary digit can be represented by [tex]b_12^1[/tex]

and so on... Then, for any binary number with more than 4 digits, you have: [tex]2^n , 2^{n-1}, ..., 2^3, 2^2, 2^1, 2^0[/tex]

By breaking a large (more than 4 digits) binary number into quartets, and re-assigning them to values of 0..15, you are actually reassigning the appropriate power of 2 (the exponent) for all digits more significant than [tex]b_32^3[/tex]

Obviously, for the 1st quartet (4 least significant bits), which is [tex]b_3b_2b_1b_0[/tex], the value is already correct (there is no reassignment of exponents) and the quartet's value is [tex]b_32^3+b_22^2+b_12^1+b_02^0[/tex]

For the 2nd quartet, [tex]b_7b_6b_5b_4[/tex], you are essentially changing the exponents from [tex]2^7, 2^6, 2^5, and \phantom{1}2^4[/tex] to [tex]2^3, 2^2, 2^1, and\phantom{1}2^0[/tex]
This results in the 2nd quartet having the value [tex]b_72^3+b_62^2+b_52^1+b_42^0[/tex] (The actual value is, of course: [tex]b_72^7+b_62^6+b_52^5+b_42^4[/tex])

What you've done here is subtracted 4 from each of the exponents in the 2nd quartet: [tex]b_72^{7-4}+b_62^{6-4}+b_52^{5-4}+b_42^{4-4}[/tex]

Using one of the laws of exponents: [tex]\frac{X^a}{X^b}=X^{a-b}[/tex], we can show that 2nd quartet as: [tex]b_7\frac{2^7}{2^4}+b_6\frac{2^6}{2^4}+b_5\frac{2^5}{2^4}+b_4\frac{2^4}{2^4}[/tex]

We can then factor out [tex]\frac{1}{2^4}[/tex], resulting in [tex]\frac{1}{2^4}(b_72^7+b_62^6+b_52^5+b_42^4)[/tex]

And, since [tex]2^4=16[/tex], what you've effectively done, is divided the 2nd quartet by 16!

Extending this same technique out to the next quartet, you'll find that you will have divided that quartet by [tex]2^8=16^2[/tex]

Remember also, that each more significant digit in hexidecimal (base 16) is a successively larger power of 16, such that you have
[tex]h_n16^n+h_{n-1}16^{n-1}+...+h_316^3+h_216^2+h_116^1+h_016^0[/tex]
with [tex]h_n[/tex] = 0...9, A..F
 
So, for each quartet [tex]Q_n \phantom{0} (n\geqq1)[/tex], you obtain the hex digit by dividing the binary value of the quartet by [tex]16^{n-1}[/tex]
 
Thank you for the help all of you.

So do I need to write it like this:

[tex] 16^{(m+n-3)/4)}(b_{m+n}2^3+b_{m+n-1}2^2+...+b_{m+n-3}2^0)+16^{(m+n-3)/4 -1}(b_{m+n-4}2^3+...+b_{m+n-7}2^0)...+16^0(b_32^3+b_22^2+b_12^1+b_02^0)[/tex]
 
njama said:
Hello PF members!

I am interested in proving that the conversion of binary to hex is valid.

Example: 1000100100110111

Breaking into 'quartets' 1000 1001 0011 0111
Of course 100002= 16 so while 01112= (01112)(1)= (01112)(160)= 7(160), the second set, "00112", is (00112)(16)= (00112)(161)= 3(161, the third "10012 is (10012)(162)= 9(162), and the fourth "10002" is (10002)(163)= 7(163.


Now using the fact that 24 = 0...15

1000 = 8, 1001 = 9, 0011 = 3, 0111 = 7. So

10001001001101112=893716

I can create the table starting from 0000 to 1111. I need to prove that this conversion really works.

I would start the proof by stating that the number in binary form is:

[tex]b_1b_2...b_{n-1}b_n[/tex]

If n mod 4 == 0 (if the remainder of the division of n with 4 is zero) then:

[tex]b_1b_2b_3b_4 ... ... ... b_{n-3}b_{n-2}b_{n-1}b_n[/tex]

But how to prove afterward?

else we can add m zeroes so that (m+n) mod 4 ==0.

By adding zeroes before the binary number I can easily prove that nothing is changed.

[tex](*)=b_1b_2...b_{n-1}b_n=b_n*2^0 + b_{n-1}*2^1+...+b_2*2^{n-2}+b_1*2^{n-1}[/tex]

[tex]00..00b_1b_2...b_{n-1}b_n=b_n*2^0 + b_{n-1}*2^1+...+b_2*2^{n-2}+b_1*2^{n-1}+0*2^n+0*2^{n+1}...+0*2^{n+m}=(*)[/tex]

Any help would be appreciated.
 
Ok, I believe to makes things better I should use m+n-1 = 4k
 
  • #10
njama said:
Ok, I believe to makes things better I should use m+n-1 = 4k

I would simplify things a little by first stating that any number (binary, or otherwise) can be led with any number of 0's and still retain the same value. That said, I would FIRST add the number of 0's needed (one, two, or three of them) to make the number of binary digits (bits) evenly divisible by 4. Then use "n" to represent the total number of bits in the binary number (including those added 0's, if any).

Then, you can write it as:

[tex]16^{\frac{n}{4}-1}(b_n2^3 + b_{n-1}2^2 + b_{n-2}2^1 + b_{n-3}2^0) + 16^{\frac{n}{4}-2}(b_{n-3}2^3 + b_{n-4}2^2 + b_{n-5}2^1 + b_{n-6}2^0) + ... + 16^1(b_72^3 + b_62^2 + b_52^1 + b_42^0) + 16^0(b_32^3 + b_22^2 + b_12^1 + b_02^0)[/tex]
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K