Skip to content

Add Euclidean division APIs and coverage#5

Merged
eisenwave merged 10 commits into
mainfrom
copilot/add-euclidean-division-functions
May 13, 2026
Merged

Add Euclidean division APIs and coverage#5
eisenwave merged 10 commits into
mainfrom
copilot/add-euclidean-division-functions

Conversation

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

The paper now includes Euclidean quotient/remainder operations, but this repo did not yet implement them. This change adds the Euclidean APIs and covers the key correctness property: the remainder is always non-negative and strictly less than abs(y).

  • API surface

    • Add div_rem_euclid(x, y) for Euclidean quotient/remainder pairs
    • Add div_euclid(x, y) for quotient-only access
    • Add rem_euclid(x, y) as a dedicated direct remainder computation instead of projecting from div_rem_euclid
  • Implementation

    • Implement Euclidean adjustment from truncating division while preserving the invariant:
      • x == y * q + r
      • 0 <= r < abs(y) for signed inputs
    • Keep unsigned behavior aligned with ordinary division, since the remainder is already Euclidean there
    • Avoid extra Euclidean recomputation in the remainder-only path
  • Test coverage

    • Add Euclidean validation helpers alongside the existing rounding-mode checks
    • Add targeted static_assert cases for sign combinations of dividend/divisor
    • Extend fuzz coverage for both int and unsigned to verify:
      • quotient/remainder identity holds
      • div_euclid / rem_euclid match div_rem_euclid
      • Euclidean remainder stays in range
static_assert(div_rem_euclid(-8,  3) == div_result<int>{-3, 1});
static_assert(div_rem_euclid(-8, -3) == div_result<int>{ 3, 1});
static_assert(div_rem_euclid( 8, -3) == div_result<int>{-2, 2});

static_assert(div_euclid(-8, 3) == -3);
static_assert(rem_euclid(8, -3) == 2);

Copilot AI and others added 6 commits May 13, 2026 08:38
Agent-Logs-Url: https://github.com/eisenwave/integer-division/sessions/c85ad039-95b9-4128-9b7d-5e78ee454c16

Co-authored-by: eisenwave <22040976+eisenwave@users.noreply.github.com>
Agent-Logs-Url: https://github.com/eisenwave/integer-division/sessions/c85ad039-95b9-4128-9b7d-5e78ee454c16

Co-authored-by: eisenwave <22040976+eisenwave@users.noreply.github.com>
Agent-Logs-Url: https://github.com/eisenwave/integer-division/sessions/c85ad039-95b9-4128-9b7d-5e78ee454c16

Co-authored-by: eisenwave <22040976+eisenwave@users.noreply.github.com>
Agent-Logs-Url: https://github.com/eisenwave/integer-division/sessions/c85ad039-95b9-4128-9b7d-5e78ee454c16

Co-authored-by: eisenwave <22040976+eisenwave@users.noreply.github.com>
Agent-Logs-Url: https://github.com/eisenwave/integer-division/sessions/c85ad039-95b9-4128-9b7d-5e78ee454c16

Co-authored-by: eisenwave <22040976+eisenwave@users.noreply.github.com>
Agent-Logs-Url: https://github.com/eisenwave/integer-division/sessions/c85ad039-95b9-4128-9b7d-5e78ee454c16

Co-authored-by: eisenwave <22040976+eisenwave@users.noreply.github.com>
eisenwave and others added 4 commits May 13, 2026 22:14
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@eisenwave eisenwave merged commit 802eea5 into main May 13, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants