Clutch Cargo
- 18
- 0
Does anyone know how I can get Excel to convert binary to Gray Code and two's complement?
zgozvrm said:Here is the procedure for converting from binary to gray code.
Assume an n-digit binary number b_nb_{n-1}...b_2b_1b_0.
The gray code equivalent is found by the following formula:
g_n = b_n, for all other digits, g_x = b_x XOR b_{x+1}
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