GGraySorrel
AI coding workspace

Fixed-width Gray code conversion

GraySorrel is a Windows AI coding client for reviewing bit-level representations in a project folder. Connect a compatible model and inspect how its proposed conversion handles the chosen width before changing your code.

● ● ●GraySorrel●
A concrete starting point · Fixed-width Gray code conversion ×
def checked_word(value, width):
    if type(width) is not int or not 1 <= width <= 16:
        raise ValueError("word.width")
    if type(value) is not int or not 0 <= value < (1 << width):
        raise ValueError("word.value")
    return value

def to_gray(value, width):
    value = checked_word(value, width)
    return value ^ (value >> 1)

def from_gray(value, width):
    value = checked_word(value, width)
    result = 0
    while value:
        result ^= value
        value >>= 1
    return result
✳Convert integer words to Gray code and back with an explicit width from one through 16 bits.
✓ ChangesReview before applying ↗
Illustrative workspace
01

Project

Test zero and the largest fitting value, rejecting Booleans, invalid widths and values that do not fit.

02

Review before applying

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

03

Connection

Base URL, credentials and a reachable server.

Workflows

Fixed-width Gray code conversion

Workflows ↗
A concrete starting point
def checked_word(value, width):
    if type(width) is not int or not 1 <= width <= 16:
        raise ValueError("word.width")
    if type(value) is not int or not 0 <= value < (1 << width):
        raise ValueError("word.value")
    return value

def to_gray(value, width):
    value = checked_word(value, width)
    return value ^ (value >> 1)

def from_gray(value, width):
    value = checked_word(value, width)
    result = 0
    while value:
        result ^= value
        value >>= 1
    return result
AI coding workspace

Keep bit-width assumptions visible throughout a change

GraySorrel is a Windows AI coding workspace for making representation assumptions visible during development. Bring the conversion code and its consumer into a project conversation, then state which values and widths the interface accepts. That context helps the model discuss a concrete change instead of suggesting a general routine with different boundaries.

Consider a fixed-width Gray-code conversion as a task. Ask for an inspection of forward and reverse conversion together, including the shared input check. Provide a few known values and a width-boundary case, then request only the corrections needed for your intended contract. The example gives the conversation a testable target.

Review how the proposal handles values outside the chosen width. Silent truncation and explicit rejection lead to different software behavior, even if ordinary conversions agree. Run the project tests, compare round trips within the supported range and inspect the caller’s error handling. Keep exact expected encodings as well as reversible examples.

Connect a model through a supported OpenAI-compatible or Anthropic endpoint, adding credentials if required. Uncensored AI model choice applies when your endpoint offers such a model; its actual restrictions still matter. Tool support and context capacity depend on the model and server, while you retain responsibility for the contract and final patch.

Reviewing a bit-representation change

Are round trips enough to verify an encoding?

No. Two functions can reverse each other while implementing the wrong mapping. Include independently known encodings as well as round-trip checks, and inspect how the consuming code interprets the result before accepting the proposed change.

Should values wider than the requested word be masked?

Specify whether your contract rejects them or deliberately truncates them. Ask the model to trace existing validation and caller expectations. Masking is a behavior change if callers previously received an error, even when it simplifies the conversion.

How much of the consumer should I include?

Start with the code that stores, compares or transmits the converted value, plus relevant tests. That reveals assumptions about width and representation. Expand the context only when inspection identifies another dependency needed to understand the proposed edit.

Can a chosen model make unsupported width claims reliable?

No. Verify the supported range in code and tests. Also inspect tool execution: using a separately running local model server does not make every connected tool local or establish where those tests actually run.

Get the Windows app ↗

GraySorrel · Updated 2026-10-25