[PR #1524] [CLOSED] Added Binary to Gray code #2133

Open
opened 2026-01-29 15:29:15 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/TheAlgorithms/C/pull/1524
Author: @Craniace
Created: 10/31/2025
Status: Closed

Base: masterHead: master


📝 Commits (2)

  • bf74ad3 Create bonary_to_gray.c
  • 93858ba Rename bonary_to_gray.c to binary_to_gray.c

📊 Changes

1 file changed (+55 additions, -0 deletions)

View changed files

conversions/binary_to_gray.c (+55 -0)

📄 Description

Description of Change

Added a new algorithm to convert a binary number to its Gray code equivalent in the bit_manipulation directory.
The algorithm performs bitwise XOR between the binary number and its right-shifted version to generate the Gray code.

References

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:
Added binary_to_gray.c — a simple and efficient implementation using bitwise operators with example and validation logic.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/TheAlgorithms/C/pull/1524 **Author:** [@Craniace](https://github.com/Craniace) **Created:** 10/31/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (2) - [`bf74ad3`](https://github.com/TheAlgorithms/C/commit/bf74ad362ff3b26a47168d6fe3f21b3d1b3d2fe5) Create bonary_to_gray.c - [`93858ba`](https://github.com/TheAlgorithms/C/commit/93858ba5808f2cd1e32de66ea1abaa0d4b3fee58) Rename bonary_to_gray.c to binary_to_gray.c ### 📊 Changes **1 file changed** (+55 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `conversions/binary_to_gray.c` (+55 -0) </details> ### 📄 Description #### Description of Change Added a new algorithm to convert a **binary number to its Gray code equivalent** in the **bit_manipulation** directory. The algorithm performs bitwise XOR between the binary number and its right-shifted version to generate the Gray code. #### References - [Wikipedia – Gray code](https://en.wikipedia.org/wiki/Gray_code) #### Checklist - [x] Added description of change - [x] Added file name matches [File name guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#File-Name-guidelines) - [x] Added tests and example, test must pass - [x] Relevant documentation/comments is changed or added - [x] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) - [x] Search previous suggestions before making a new one, as yours may be a duplicate. - [x] I acknowledge that all my contributions will be made under the project's license. Notes: Added `binary_to_gray.c` — a simple and efficient implementation using bitwise operators with example and validation logic. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 15:29:16 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#2133