Professional Documents
Culture Documents
http://www.daniweb.com/software-development/c/code/216355
DaniWeb is currently in read-only mode while we migrate to the new infrastructure. We will be back tomorrow. Sorry for the inconvenience.
Software Development > C > Gray Code Conversion
C Code Snippet
Views: 25279
Permalink
What Next? Check out this Code Snippet: Polynomial Addition Using Linked List
1 of 3
http://www.daniweb.com/software-development/c/code/216355
balajisankar
Newbie Poster Offline 2 posts since Jan 2010
Permalink
-2
folderol
Newbie Poster Offline 1 posts since Feb 2011
Permalink
What Next? Check out this Code Snippet: Polynomial Addition Using Linked List
2 of 3
http://www.daniweb.com/software-development/c/code/216355
28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. }
for(i = 0; i < SIZE; i ++){ printf("%d",bits[i]); } /* in-line gray code conversion */ for(i = SIZE-1; i > 0; i --){ bits[i] = bits[i] ^ bits[i - 1]; } /* printing gray code */ printf("\n Gray code for(i = 0; i < SIZE; i ++){ printf("%d",bits[i]); } /* in-line conversion back to binary */ for(i = 1; i < SIZE; i++){ bits[i] = bits[i] ^ bits[i - 1]; } /* reprinting binary */ printf("\n Restored binary for(i=0;i<SIZE;i++){ printf("%d",bits[i]); } /* convert back to decimal */ num = 0; for (i = 0; i < SIZE; i ++){ num = (num<<1) | bits[i]; } /* reprinting decimal number */ printf("\n Restored decimal "); printf("%lu",num); printf("\n"); "); ");
Message:
Open GL
Tags
code , conversion , gray , int , string
array
c++
code
coding concatenation conversion convert count css database decimal design developer dictionary eclipse eof
error file find float format formatting forum function functions game getline gui help! hex hexadecimal html improve increment index input int integer
java
key list login loop message mips month number object output page php print
printf problem program programming python python-2.7 query random read replace return reverse save search software sort split
string
substring switch text textbox type unicode validation variable variables vb vb.net vector visual
words year
Follow us on
What Next? Check out this Code Snippet: Polynomial Addition Using Linked List
3 of 3