Binary to Gray Code Converter

Разработчик
РЕКЛАМА · УДАЛЯТЬ?

Single Conversion


Пакетное преобразование

Conversion Result


Step-by-Step XOR Visualization


Conversion Table


Результаты пакета


Ссылка

РЕКЛАМА · УДАЛЯТЬ?

Гид

Binary to Gray Code Converter

Binary to Gray Code Converter

Convert between binary and Gray code (reflected binary code) instantly. Enter a binary number, Gray code, or decimal value and see all representations with a step-by-step XOR visualization showing exactly how the conversion works. Supports up to 64-bit values with batch conversion mode.

Как использовать

Select your input type (Binary, Gray Code, or Decimal), enter a value, and choose a bit width (Auto, 4-bit, 8-bit, 16-bit, 32-bit, or 64-bit). The converter instantly displays all representations: binary, Gray code, decimal, hex, and octal — each with a copy button. View the step-by-step XOR visualization to understand exactly how the conversion works bit by bit. Check the conversion table for quick reference, or use batch mode to convert multiple values at once.

Функции

  • Двунаправленное преобразование — Convert Binary to Gray code, Gray code to Binary, or start from Decimal. All conversions happen instantly with no button clicks needed.
  • XOR Step-by-Step Visualization — See the exact XOR operation for each bit position with color-coded pairs, making it easy to understand and verify the conversion algorithm.
  • Несколько форматов вывода — Binary, Gray code, decimal, hexadecimal, and octal — each with a dedicated copy button for quick use.
  • Conversion Table — Reference table showing Decimal, Binary, and Gray code for ranges 0-15, 0-31, 0-63, or 0-255. Current input value is highlighted.
  • Пакетный режим — Convert multiple values at once. Enter one value per line, select input and output formats, and get results in a table with copy-all functionality.
  • Flexible Bit Width — Auto-detect or manually set to 4-bit, 8-bit, 16-bit, 32-bit, or 64-bit. Uses BigInt for values exceeding 32 bits.
  • Справочное руководство — Explanation of Gray code, the XOR algorithm, single-bit transition property, reflected construction, and real-world applications.

What is Gray Code?

Gray code (also called reflected binary code) is a binary numeral system where two successive values differ in only one bit. Standard binary counting changes multiple bits simultaneously (e.g., 0111 to 1000 changes all four bits), which can cause glitches in hardware. Gray code eliminates this problem — each increment changes exactly one bit. This property makes Gray code essential for rotary encoders, analog-to-digital converters, Karnaugh maps, error correction, and any application where simultaneous bit transitions cause errors.

РЕКЛАМА · УДАЛЯТЬ?

How do you convert binary to Gray code?

The conversion uses a simple XOR operation: the most significant bit (MSB) stays the same, and each subsequent Gray code bit is the XOR of the current and previous binary bits. In formula form: gray[0] = binary[0], gray[i] = binary[i-1] XOR binary[i]. Alternatively, you can compute it as: gray = binary XOR (binary >> 1). For example, binary 1011 becomes Gray code 1110: the MSB stays 1, then 1 XOR 0 = 1, 0 XOR 1 = 1, 1 XOR 1 = 0.

How do you convert Gray code back to binary?

The reverse conversion builds the binary number from the MSB down: the MSB stays the same, and each subsequent binary bit is the XOR of the previous binary bit and the current Gray code bit. In formula form: binary[0] = gray[0], binary[i] = binary[i-1] XOR gray[i]. You can also compute it iteratively: start with mask = gray, then repeatedly do mask >>= 1 and gray ^= mask until mask is 0. The result is the binary value.

Why is Gray code used in rotary encoders?

Rotary encoders measure angular position using multiple tracks read by sensors. With standard binary, transitioning between certain values (like 0111 to 1000) requires all bits to change simultaneously — but mechanical sensors cannot switch at exactly the same instant, causing brief erroneous readings. Gray code guarantees that only one bit changes per step, eliminating these transitional errors. This makes rotary encoders reliable even at high speeds, which is critical in industrial automation, robotics, and motor control.

Отправляются ли мои данные на сервер?

No — all conversions are performed entirely in your browser using JavaScript bitwise operations and BigInt for large values. No data is transmitted to any server. The XOR calculations, table generation, and batch processing all run client-side with zero network requests.

Хотите убрать рекламу? Откажитесь от рекламы сегодня

Установите наши расширения

Добавьте инструменты ввода-вывода в свой любимый браузер для мгновенного доступа и более быстрого поиска

в Расширение Chrome в Расширение края в Расширение Firefox в Расширение Opera

Табло результатов прибыло!

Табло результатов — это интересный способ следить за вашими играми, все данные хранятся в вашем браузере. Скоро появятся новые функции!

РЕКЛАМА · УДАЛЯТЬ?
РЕКЛАМА · УДАЛЯТЬ?
РЕКЛАМА · УДАЛЯТЬ?

новости с техническими моментами

Примите участие

Помогите нам продолжать предоставлять ценные бесплатные инструменты

Купи мне кофе
РЕКЛАМА · УДАЛЯТЬ?