Skip to content

Conversation

@aryan7071
Copy link
Contributor


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 status: passed
  • task: lint_package_json status: passed
  • task: lint_repl_help status: passed
  • task: lint_javascript_src status: passed
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: passed
  • 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: na
  • 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: passed
  • task: lint_license_headers status: passed ---

Description

What is the purpose of this pull request?

This pull request:

  • add constants/float16/fourth-root-eps

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.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

---
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
    status: passed
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - 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: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 7, 2026
---
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
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - 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: na
  - 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
---
@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
constants/float16/fourth-root-eps $\color{green}53/53$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}0/0$
$\color{green}+100.00%$
$\color{green}53/53$
$\color{green}+100.00%$

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

@Planeshifter Planeshifter changed the title feat: add @stdlib/constants/float16/fourth-root-eps feat: add constants/float16/fourth-root-eps Jan 8, 2026

#### FLOAT16_FOURTH_ROOT_EPS

[Fourth root][nth-root] of [single-precision floating-point epsilon][@stdlib/constants/float16/eps].
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
[Fourth root][nth-root] of [single-precision floating-point epsilon][@stdlib/constants/float16/eps].
[Fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps].

Comment on lines +24 to +25
var pow = require( '@stdlib/math/base/special/pow' );
var sqrtf = require( '@stdlib/math/base/special/sqrtf' );
Copy link
Member

@Neerajpathak07 Neerajpathak07 Jan 8, 2026

Choose a reason for hiding this comment

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

Suggested change
var pow = require( '@stdlib/math/base/special/pow' );
var sqrtf = require( '@stdlib/math/base/special/sqrtf' );
var pow = require( '@stdlib/math/base/special/pow' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );

you need to use the double-precision version for the test and then convert them to float16.

});

tape( 'the exported value equals the fourth root of the difference between one and the smallest value greater than one which is representable as a half-precision floating-point number (2**-10)', function test( t ) {
var expected = float64ToFloat16(sqrtf(sqrtf(float64ToFloat16( pow( 2.0, -10.0 ) ))));
Copy link
Member

@Neerajpathak07 Neerajpathak07 Jan 8, 2026

Choose a reason for hiding this comment

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

This is incorrect sqrtf represents a float dtype and wrapping float64ToFloat16 around doesn't give out the half-precision value.

/**
* Macro for the fourth root of half-precision floating-point epsilon.
*/
#define STDLIB_CONSTANT_FLOAT16_FOURTH_ROOT_EPS 0.1767578125f
Copy link
Member

Choose a reason for hiding this comment

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

You need to remove the C header files as stdlib_float16_t which cannot be readily supported in a macro as of now.

@Neerajpathak07
Copy link
Member

@aryan7071 Left a few comments. Also, do double check if the return value fits the half-precision limit.

@Neerajpathak07
Copy link
Member

Neerajpathak07 commented Jan 8, 2026

Ohh turns out this package has been worked on in #9250.

@Neerajpathak07 Neerajpathak07 added the Potential Duplicate There might be another pull request resolving the same issue. label Jan 8, 2026
@aryan7071
Copy link
Contributor Author

Oh okay, @Neerajpathak07. In that case, I’ll close this for now. That PR is already 20 days old if it doesn’t move forward, I’d be happy to make the changes and commit them. Your call.

@stdlib-bot stdlib-bot removed the Potential Duplicate There might be another pull request resolving the same issue. label Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants