Binary to Gray Code

I need some help with these instructions, thanks!

Write a function called binary2Gray that takes an unsigned character and returns an unsigned character that is equal to the "reflected" Gray code equivalent of the input character. To convert to Gray code, each bit of the result is equal to an exclusive-OR of that bit position with the bit position to the left of the original number. Assume a leading zero is in front of the original number, so the MSB (most significant bit) of the result is the same as the MSB of the original. Note: if B_i and G_i are the i-th bits of the binary and Gray code values, respectively, then G_i = B_i ^ B_i+1.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories