Skip to content

Add the pi constant word - #579

Merged
thedavidmeister merged 4 commits into
mainfrom
2026-09-07-pi-word
Sep 9, 2026
Merged

thedavidmeister merged 4 commits into
mainfrom
2026-09-07-pi-word

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Adds a pi constant word, mirroring e (LibOpE). #535 rebased onto the split library: LibOpPi.sol, its registration in LibAllStandardOps between mul and power (ALL_STANDARD_OPS_LENGTH 72 -> 73, later word indices shift by one), and LibOpPi.t.sol.

The word reads LibDecimalFloat.FLOAT_PI from rain-math-float 0.2.1 (rain.math.float#274), exactly as e reads FLOAT_E. The library owns the constant and its checks: packLossless of the 67-digit coefficient at -66 in Solidity, and π by Machin's formula in Rust bound to the library source. Nothing about the value is restated here.

Stacked on #580 (the pin bump). Closes #225. Supersedes #535.

QA

  • Discriminating tests: LibOpPi.t.sol parses _: pi(); and evals to LibDecimalFloat.FLOAT_PI, checks integrity (0 in, 1 out), the disallowed operand, and bad input / output arity; LibAllStandardOps.t.sol pins pi at word index 59 with every later word shifted. 14 tests across those suites pass over the new pins; the full suite is on Pin rain-math-float 0.2.1 and rain-math-float-deploy 0.1.2 #580.
  • Mutations applied: run returning FLOAT_E instead of FLOAT_PI fails testOpPiRun against referenceFn; the registration is pinned by the word-order test (drop the pi entry and index 59 reads power).
  • Oracle: the library's constant, whose value the library tests against Machin's formula and the packed decimal; this PR asserts the word pushes it.
  • Category check: word for pi #225 asks for a pi word; delivered as the e word is built, with no value carried in rainlang.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QyCCzi9WZPhuXcU1hwr2bq

Mirrors e (LibOpE): LibOpPi with integrity (0 in, 1 out), run pushing
the constant, and referenceFn; registered in LibAllStandardOps between
mul and power (72 -> 73 ops). The coefficient is pi rounded to nearest
at 66 places, the same packing as FLOAT_E.

#535 rebased onto the split library; the interpreter bytecode
consequence is rainlang.deploy's next bump and release.

Closes #225.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QyCCzi9WZPhuXcU1hwr2bq
@thedavidmeister thedavidmeister mentioned this pull request Sep 7, 2026
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 7650ae3c-6082-48f6-a61e-22ce39d1ff03

📥 Commits

Reviewing files that changed from the base of the PR and between 16c2d92 and 76753c3.

📒 Files selected for processing (4)
  • src/lib/op/LibAllStandardOps.sol
  • src/lib/op/math/LibOpPi.sol
  • test/src/lib/op/LibAllStandardOps.t.sol
  • test/src/lib/op/math/LibOpPi.t.sol

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds the pi opcode with a fixed FLOAT_PI result, registers it among standard operations, and tests integrity, runtime evaluation, registry ordering, invalid input/output counts, and disallowed operands.

Changes

Pi opcode

Layer / File(s) Summary
Implement and register pi
src/lib/op/math/LibOpPi.sol, src/lib/op/LibAllStandardOps.sol
Defines FLOAT_PI, a zero-input and one-output integrity contract, stack execution, and a reference function. Registers the opcode and increases the standard opcode count to 73.
Validate pi behavior
test/src/lib/op/math/LibOpPi.t.sol, test/src/lib/op/LibAllStandardOps.t.sol
Tests integrity, runtime output, evaluation, registry ordering, invalid input/output counts, and disallowed operands.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 76753

This adds a pi constant word that evaluates to the expected float value while rejecting invalid operands and arities. The implementation and registry behavior are covered, with no concrete current-head merge risk identified.

Sequence Diagram(s)

sequenceDiagram
  participant I_INTERPRETER
  participant LibAllStandardOps
  participant LibOpPi
  participant Stack
  I_INTERPRETER->>LibAllStandardOps: resolve pi opcode
  LibAllStandardOps->>LibOpPi: execute registered run function
  LibOpPi->>Stack: push FLOAT_PI
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The pull request implements the pi constant word requested by issue [#225]. It adds the opcode, registers it in the standard operation registry, and adds integrity, runtime, parsing, and ordering test…
Out of Scope Changes check ✅ Passed All changes support the pi constant word objective in [#225]. The implementation, registry update, and tests are in scope. No unrelated deployment or generated-file changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding the pi constant word.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-09-07-pi-word

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

The other tests compare the op to the literal; this one compares the
literal to pi rounded to nearest at 66 places.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QyCCzi9WZPhuXcU1hwr2bq
@thedavidmeister
thedavidmeister marked this pull request as draft September 7, 2026 14:16
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Draft until FLOAT_PI lands in rain.math.float beside FLOAT_E and this repo's rain-math-float pin moves to that release; then LibOpPi reads LibDecimalFloat.FLOAT_PI exactly as LibOpE reads FLOAT_E, and the local literal goes.

baku-ccron and others added 2 commits September 9, 2026 04:48
The library defines it as of rain-math-float 0.2.1, exactly as FLOAT_E; the
local literal and its packing test go, the library carries both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QyCCzi9WZPhuXcU1hwr2bq
@thedavidmeister
thedavidmeister changed the base branch from main to 2026-09-09-rain-math-float-0.2.1 September 9, 2026 04:51
@thedavidmeister
thedavidmeister marked this pull request as ready for review September 9, 2026 04:51
@thedavidmeister
thedavidmeister changed the base branch from 2026-09-09-rain-math-float-0.2.1 to main September 9, 2026 04:57
@thedavidmeister
thedavidmeister merged commit 02c2527 into main Sep 9, 2026
5 checks passed
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

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.

word for pi

1 participant