Skip to content

Add sqrt button label state feedback while irrational - #112

Closed
klh wants to merge 1 commit into
masterfrom
agent/111
Closed

klh wants to merge 1 commit into
masterfrom
agent/111

Conversation

@klh

@klh klh commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Closes #111

Summary

  • Show a display-only ~ prefix for irrational square roots through both r and √; rational decimal roots remain bare.
  • Carry approximation provenance through pending operands, intermediate chains and repeat equals. Fresh/edited entries, recall and clear reset their entry marker without corrupting pending operands.
  • Keep numeric operands, memory, history and existing arithmetic unchanged. Document behavior in README and the cell-to-test matrix in 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 fail
  • node --test: 475 pass, 0 fail
  • git diff origin/HEAD --check: passes

Copilot AI balanced review requested due to automatic review settings November 17, 2026 05:42
@klh

klh commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Independently verified the existing PR head 81c71d7 with node --test: 475 passed, 0 failed. This unattended run found this same-issue PR already open while publishing, so it preserved the remote branch rather than overwrite or create a duplicate PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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

Comment thread script.js
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) ||
@klh klh closed this Nov 23, 2026
@klh
klh deleted the agent/111 branch November 23, 2026 09:05
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