Skip to content

fix: handle -0 and -infinity bases in math/base/special/pow and powf - #16251

Open
0PrashantYadav0 wants to merge 1 commit into
stdlib-js:developfrom
0PrashantYadav0:fix/pow-negative-zero
Open

0PrashantYadav0 wants to merge 1 commit into
stdlib-js:developfrom
0PrashantYadav0:fix/pow-negative-zero

Conversation

@0PrashantYadav0

@0PrashantYadav0 0PrashantYadav0 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • fixes math/base/special/pow for x = -0 (the x = 0 check missed the sign bit), so, e.g., pow( -0.0, -1/6 ) returned ~9.65e53 instead of Infinity. This also fixes pow( -Infinity, y ), which is computed as pow( -0.0, -y ).
  • restricts the y = ±0.5 shortcuts in pow and powf to x > 0, as sqrt( -0.0 ) is -0 and sqrt( -Infinity ) is NaN. E.g., pow( -0.0, -0.5 ) returned -Infinity and pow( -Infinity, 0.5 ) returned NaN, instead of Infinity.
  • adds tests for -0 and -Infinity raised to non-integer powers.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

I used Claude Code to review this PR.


@stdlib-js/reviewers

… `powf`

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@0PrashantYadav0
0PrashantYadav0 requested a review from a team October 19, 2026 12:32
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Oct 19, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/pow $\\color{red}1376/1382$
$\\color{green}+99.57\\%$
$\\color{red}120/122$
$\\color{green}+98.36\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{red}1376/1382$
$\\color{green}+99.57\\%$
math/base/special/powf $\\color{red}1219/1253$
$\\color{green}+97.29\\%$
$\\color{red}102/105$
$\\color{green}+97.14\\%$
$\\color{red}8/10$
$\\color{green}+80.00\\%$
$\\color{red}1219/1253$
$\\color{green}+97.29\\%$

The above coverage report was generated for the changes in this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants