Skip to content

2025 08 27 maximize constants#112

Closed
thedavidmeister wants to merge 2 commits intomainfrom
2025-08-27-maximize-constants
Closed

2025 08 27 maximize constants#112
thedavidmeister wants to merge 2 commits intomainfrom
2025-08-27-maximize-constants

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

@thedavidmeister thedavidmeister commented Aug 27, 2025

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • Bug Fixes

    • Improved numerical stability and representation of the value 1.0 to ensure consistent behavior in exponentiation and related calculations.
    • Fine-tuned precision thresholds to reduce false negatives in round‑trip accuracy checks.
  • Tests

    • Reorganized test suites and updated gas snapshots to reflect new groupings.
    • Expanded and adjusted test inputs and bounds for edge cases.
    • Updated expectations to align with the refined numeric representation and tolerances.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 27, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Updates the decimal float “one” constant to a new packed representation, adjusts related tests and tolerance, tightens one test’s input bound, and refreshes the gas snapshot reflecting reorganized test group names and metrics. No new APIs; behavior aims to preserve numeric value while changing internal encoding.

Changes

Cohort / File(s) Summary of Changes
Snapshot reorg
\.gas-snapshot
Renamed/reclassified test suites to implementation-oriented groupings; updated run counts and gas metrics; snapshot entries recalibrated.
Decimal float constant update
src/lib/LibDecimalFloat.sol
Replaced FLOAT_ONE from 1 to packed 1.0 as 1e67 × 10^-67 (different mantissa/exponent encoding).
Constants test alignment
test/src/lib/LibDecimalFloat.constants.t.sol
Updated expected FLOAT_ONE encoding from packLossless(1, 0) to packLossless(1e67, -67).
Pow test tolerance
test/src/lib/LibDecimalFloat.pow.t.sol
Increased diffLimit() threshold from packLossless(94, -3) to packLossless(96, -3).
Division test domain tweak
test/src/lib/implementation/LibDecimalFloatImplementation.div.t.sol
Narrowed exponent upper bound by 1 for testDivByNegativeOneFloat (from type(int256).max to type(int256).max - 1).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • 2025 07 30 min const #90 — Also modifies LibDecimalFloat constants and corresponding tests; likely related to constant encoding updates.
  • 2025 04 15 pack #28 — Changes to pack/unpack and bit layout (224-bit coefficient/32-bit exponent) align with altering the representation of FLOAT_ONE.

Suggested reviewers

  • hardyjosh

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between eaeb693 and 5dd6b80.

📒 Files selected for processing (5)
  • .gas-snapshot (2 hunks)
  • src/lib/LibDecimalFloat.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.constants.t.sol (1 hunks)
  • test/src/lib/LibDecimalFloat.pow.t.sol (1 hunks)
  • test/src/lib/implementation/LibDecimalFloatImplementation.div.t.sol (1 hunks)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2025-08-27-maximize-constants

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

1 participant