Decimal To Gray Code
How This Converter Works
Converts a non-negative decimal integer to reflected binary Gray code; spaces and underscores are ignored, but signs and other characters are rejected.
Formula or rule
Remove whitespace and underscores; require decimal digits only, convert to binary, then XOR the binary integer with itself shifted right by one.
Example
- Input
- 10
- Calculation
- 10₁₀ = 1010₂; leading bit 1 followed by adjacent XOR bits 1,1,1.
- Result
- 1111