Repository navigation
Conversation
Collaborator
Author
|
Independently verified the existing PR head |
There was a problem hiding this comment.
🟡 Changes recommended
The percent operation updates lastResult without synchronizing its approximation flag, causing exact recalled or edited values to incorrectly regain an approximation prefix.
1 open issue
What changed in this PR
Adds display-only ~ feedback for irrational square roots, addressing #111 while keeping numeric values and history unchanged.
Changes:
- Tracks approximation through pending operations, chaining, and repeat equals.
- Adds 50 regression cases and updates existing irrational-root expectations.
- Documents marker behavior and the test coverage matrix.
| File | Description |
|---|---|
| tests/tilde.test.cjs | Adds coverage for approximation markers and entry-state transitions. |
| tests/sqrt.test.js | Updates fallback square-root expectations to include ~. |
| script.js | Adds rational-root detection, approximation tracking, and display prefixes. |
| README.md | Explains when approximation markers appear and reset. |
| docs/TEST-SWEEP.md | Documents coverage and reported validation results. |
Review effort: Balanced
| if (!Number.isFinite(value) || value < 0) return | ||
| // Track provenance, not the floating-point text: later arithmetic may still | ||
| // depend on a rounded root, even if its displayed result looks integral. | ||
| this.currentApproximate = (empty ? this.lastResultApproximate : this.currentApproximate) || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #111
Summary
~prefix for irrational square roots through bothrand√; rational decimal roots remain bare.docs/TEST-SWEEP.md.Tests first / regression coverage
Added 50 dependency-free cases in
tests/tilde.test.cjs, spanning keyboard/button parity, rational fractions, scientific notation, both operand positions × all operators, editing, sign changes, memory, fallback sqrt and error recovery. Initial matrix produced 28 behavioral failures before implementation. Updated the two existing irrational sqrt fallback expectations.The decimal-coefficient root check avoids falsely marking rational roots such as sqrt(0.01) due to floating-point multiplication (
0.1 * 0.1 !== 0.01). No unrelated production bug fixes or dependencies.Validation
Rebased onto current master (including AC letter aliases) before pushing.
node --test tests/tilde.test.cjs: 50 pass, 0 failnode --test: 475 pass, 0 failgit diff origin/HEAD --check: passes