Skip to content

Name newBase, not x, when Log is given a base outside its domain [patch] - #197

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/log-base-param-name
Nov 10, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/log-base-param-name

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Log(x, newBase, significantDigits) passed the base to the single-argument Log, and that method's guard names x. So Log(5, -2) threw ArgumentOutOfRangeException with ParamName = "x" and ActualValue = -2. It also worked out Log(5) to full working precision before throwing.

The method now checks x and then newBase, each under its own name, before it computes either logarithm. Base one still throws DivideByZeroException, as documented.

Test: TestLogInABaseNamesTheArgumentOutsideTheDomain checks the following:

  • Log(5, -2) and Log(5, 0, 20) name newBase.
  • Log(-5, 2) names x.
  • Base one still throws DivideByZeroException.

Without the fix, the test fails on its first ParamName assertion. The full suite passes: 587 tests.

Fixes #196


Generated by Claude Code

Log(x, newBase) passed the base to the single-argument Log, whose guard names
x, so Log(5, -2) reported a bad x with the base's value, after working out
Log(x) for nothing. Check each argument under its own name first.

Fixes #196

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3RtuaocwQ2QRF7djh
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

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.

Log(5, -2) throws ArgumentOutOfRangeException naming parameter x with value -2: an invalid base is reported as an invalid argument

2 participants