Binary To Gray Code Conversion Using Python
Binary To Gray Code Conversion Using Python
Guided by - Mrs.R.Gomathi/ASP/ECE
Presented by - T. Nivetha, III-ECE-B
R. Nesiga, III-ECE-B
OBJECTIVES
• Binary Numbers is default way to store numbers, but in many applications binary
numbers are difficult to use and a variation of binary numbers is needed. This is
where Gray codes are very useful.
• Gray code has property that two successive numbers differ in only one bit because
of this property gray code does the cycling through various states with minimal
effort and used in K-maps, error correction, communication etc.
THE GRAY CODE
BINARY TO GRAY CODE CONVERSION
The MSB in the gray code is the same as the corresponding MSB in the binary
number.
Going from left to right, add each adjacent pair of binary code bits to get the next
gray code bit. Discard carries.
Convert 10110 to gray code
1+0+1+1+0 binary
| | | | |
1 1 1 0 1 gray
TRUTH TABLE
PROGRAM
def convert_gray(binary):
binary = Int(binary, 2)
binary ^= (binary >> 1)
return bin(binary)[2:]
binary_num = input(“BINARY NUMBER : ”)
gray _code = convert_gray(binary_num)
print(“EQUIVALENT GRAY CODE IS: ”,gray_code)
OUTPUT:
BINARY NUMBER: 101100110
Gray codeword is: 111010101
APPLICATIONS
• The gray code eliminates his problem since one bit changes its values during
any transition between two numbers.
• Because of run-time typing, Python’s run time must work harder than Java`s.
Hence, is much better suited as a glue language.
advantages
• The main benefit of using binary code is that it is simply signified through
electronic devices
[1]ho, H. and Swartzlander, E. E., Adder and multiplier design in binary to gray code conversion,
IEEE Transactions on Computers, 58(6), 2009, 721-727.
http://dx.doi.org/10.1109/TC.2009.21
[2] Lent C.S., Tougaw P.D., Porod W.D., and Bernstein., G.H. Quantum cellular automata,
Nanotechnology, 4(1), 1993, 49–57.
[3] Seminario J.M, Derosa P.A, Cordova L.E and Bozard B.H., A molecular device operating at
terahertz frequencies, IEEE Transactions on Nanotechnology, 3(1), 2004, 215–218.
http://dx.doi.org/ 10.1109/TNANO.2004.824012
[4] Zhang, R., Walus, K., Wang, W., and Jullien, G. A., A method of majority logic reduction for
quantum cellular automata, IEEE Transactions on Nanotechnology, 3(4), 2008, 443-450.
http://dx.doi.org/ 10.1109/TNANO.2004.834177
[5] Hänninen, I. and Takala, J., Binary adders on quantum-dot cellular automata. Journal of Signal
Processing Systems, 58(1), 2010, 87-103. http://dx.doi.org/ 10.1007/s11265-008-0284-5
[6] Kummamuru, R. K et al., Operation of a quantum-dot cellular automata (QCA) shift register
and analysis of errors, IEEE Transactions on Electron Devices, 50(9), 2003, 1906-1913.
http://dx.doi.org/ 10.1109/TED.2003.816522
THANK YOU