Skip to content

Add min/max/clamp/signum helpers for Float/Double/Int64/UInt#3243

Merged
bobzhang merged 1 commit intomainfrom
codex/fix-issue-with-core-component
Mar 3, 2026
Merged

Add min/max/clamp/signum helpers for Float/Double/Int64/UInt#3243
bobzhang merged 1 commit intomainfrom
codex/fix-issue-with-core-component

Conversation

@bobzhang
Copy link
Contributor

@bobzhang bobzhang commented Mar 3, 2026

Motivation

  • Numeric types lacked a consistent set of small utility methods (min, max, clamp, signum) across Float, Double, Int64, and UInt, forcing callers to hand-roll common helpers.
  • Provide IEEE-style min/max semantics for floating types (when exactly one operand is NaN, return the non-NaN operand) and parity with existing Int APIs to simplify client code.

Description

  • Added Float::min, Float::max, and Float::signum to the float package implementing IEEE-style NaN handling and parity with Double::signum (float/methods.mbt).
  • Added Double::min and Double::max with the same NaN semantics (builtin/double.mbt).
  • Added Int64::min, Int64::max, and Int64::clamp (builtin/int64.mbt) and UInt::min, UInt::max, and UInt::clamp (builtin/uint.mbt).
  • Added tests covering basic behavior, NaN cases for float/double min/max, and clamp panic cases for invalid ranges; updated generated interface files (.mbti) to expose the new APIs.

Testing

  • Ran moon fmt which completed successfully.
  • Ran moon info and moon check which completed successfully and updated package interfaces.
  • Ran the full test suite with moon test and observed all tests passed (Total tests: 5790, passed: 5790, failed: 0).

Codex Task


Open with Devin

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@coveralls
Copy link
Collaborator

coveralls commented Mar 3, 2026

Pull Request Test Coverage Report for Build 2737

Details

  • 53 of 57 (92.98%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 95.668%

Changes Missing Coverage Covered Lines Changed/Added Lines %
builtin/int64.mbt 10 12 83.33%
builtin/uint.mbt 10 12 83.33%
Totals Coverage Status
Change from base Build 2735: -0.01%
Covered Lines: 12985
Relevant Lines: 13573

💛 - Coveralls

@bobzhang bobzhang force-pushed the codex/fix-issue-with-core-component branch from 900adef to 066b6d5 Compare March 3, 2026 08:00
@bobzhang bobzhang enabled auto-merge (rebase) March 3, 2026 08:01
@bobzhang bobzhang merged commit f013ddf into main Mar 3, 2026
14 checks passed
@bobzhang bobzhang deleted the codex/fix-issue-with-core-component branch March 3, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants