Clutch Cargo
- 18
- 0
Does anyone know how I can get Excel to convert binary to Gray Code and two's complement?
The discussion revolves around converting binary numbers to Gray Code and two's complement using Excel. Participants share procedures, formulas, and potential issues encountered during the conversion process.
Participants generally agree on the procedures for conversion but express differing views on the effectiveness and accuracy of the Excel methods presented. Some issues remain unresolved, particularly regarding the output of the Gray Code conversion for specific binary inputs.
Limitations include potential errors in the Excel formulas, dependence on cell formatting, and the restriction of binary digit length when using certain methods.
zgozvrm said:Here is the procedure for converting from binary to gray code.
Assume an n-digit binary number [tex]b_nb_{n-1}...b_2b_1b_0[/tex].
The gray code equivalent is found by the following formula:
[tex]g_n = b_n[/tex], for all other digits, [tex]g_x = b_x[/tex] XOR [tex]b_{x+1}[/tex]
zgozvrm said:As for doing this in Excel...
1) Enter the formula =MID(A$1,ROW()-2,1) in cells A3 through A12
2) Enter the formula =CONCATENATE(B3,B4,B5,B6,B7,B8,B9,B10,B11,B12) in cell B1
3) Enter the formula =IF(A3="","",IF(A3=A2,"0","1")) in cell B3
4) Select cell B3, copy, select cells B4 through B12, paste
Enter your binary number (up to 10 digits) in cell A1
The Gray code equivalent will be displayed in cell B1
chuckc said:I tried the Excel method above but when I put in a value of 0, it says the Gray Code equivalent is 1. And when I put in a value of 1, it still says the Gray Code equivalent is 1. Obviously there's something wrong there