Binary reflected Gray code value calculator
Calculate the reflected Gray-code integer associated with a nonnegative binary integer. Enter your values below to see the result and method.
inputs.
Related calculators
These tools cover nearby questions while keeping this page focused on its own calculation.
How to use this calculator
Calculate the reflected Gray-code integer associated with a nonnegative binary integer.
- Enter Nonnegative integer. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Define the system or input
Encode a nonnegative integer as its binary-reflected Gray-code value using g = n XOR (n >> 1). This handler accepts integers only through 2³¹−1.
Inputs and units
Enter an integer from 0 through 2³¹−1; JavaScript's bitwise operator limits this handler to the signed 32-bit nonnegative range.
- Nonnegative integer: Integer n to encode; the implemented bitwise range is 0 through 2³¹−1.
Calculation method and example
g = n XOR (n shifted right by 1).
Integer 10 maps to Gray code value 15.
Intermediate values are kept unrounded; the displayed result is rounded for readability.
Interpreting the output
The decimal result is the integer represented by the reflected Gray-code bit pattern; adjacent encoded values differ in one bit for consecutive inputs.
Assumptions and limitations
Uses 32-bit bitwise operations in JavaScript; values must be integers from 0 to 2³¹−1.
Frequently asked questions
What should I enter for this computer science calculator?
Enter an integer from 0 through 2³¹−1; JavaScript's bitwise operator limits this handler to the signed 32-bit nonnegative range.
Does this include every implementation overhead?
No. Uses 32-bit bitwise operations in JavaScript; values must be integers from 0 to 2³¹−1.
How do I use the Binary reflected Gray code value calculator?
Enter Nonnegative integer. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Binary reflected Gray code value?
g = n XOR (n shifted right by 1). Integer 10 maps to Gray code value 15. Intermediate values are kept unrounded; the displayed result is rounded for readability.
What does the Binary reflected Gray code value calculator calculate?
Calculate the reflected Gray-code integer associated with a nonnegative binary integer.
Read the calculation methodology and privacy policy.
Source: University of Wisconsin–Madison, Embeddings and simulations: binary reflected Gray code. Gives the bitwise relation gᵢ = bᵢ₊₁ XOR bᵢ, equivalent to n XOR (n >> 1).