Skip to content

feat: add number/float16/base/add#9442

Draft
Neerajpathak07 wants to merge 18 commits intostdlib-js:developfrom
Neerajpathak07:float16/base/add
Draft

feat: add number/float16/base/add#9442
Neerajpathak07 wants to merge 18 commits intostdlib-js:developfrom
Neerajpathak07:float16/base/add

Conversation

@Neerajpathak07
Copy link
Copy Markdown
Member

Resolves none.

Description

What is the purpose of this pull request?

This pull request:

  • Adds number/float16/base/add

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • none

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

@Neerajpathak07 Neerajpathak07 added the Feature Issue or pull request for adding a new feature. label Dec 30, 2025
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented Dec 30, 2025

Coverage Report

Package Statements Branches Functions Lines
number/float16/base/add $\color{green}177/177$
$\color{green}+0.00%$
$\color{green}5/5$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}177/177$
$\color{green}+0.00%$

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

@Neerajpathak07 Neerajpathak07 marked this pull request as ready for review December 30, 2025 17:40
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Dec 30, 2025
Comment thread lib/node_modules/@stdlib/number/float16/base/add/package.json Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/package.json Outdated
@Neerajpathak07 Neerajpathak07 marked this pull request as draft January 2, 2026 13:42
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jan 2, 2026
@Neerajpathak07
Copy link
Copy Markdown
Member Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Jan 2, 2026
@Neerajpathak07 Neerajpathak07 marked this pull request as ready for review January 2, 2026 13:55
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 2, 2026
@Neerajpathak07 Neerajpathak07 added Native Addons Issue involves or relates to Node.js native add-ons. C Issue involves or relates to C. and removed Needs Review A pull request which needs code review. labels Jan 2, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Jan 2, 2026
@Neerajpathak07 Neerajpathak07 added the Needs Review A pull request which needs code review. label Jan 2, 2026
Comment thread lib/node_modules/@stdlib/number/float16/base/add/benchmark/benchmark.native.js Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/examples/c/example.c Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/examples/index.js Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/test/test.native.js Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/README.md Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/README.md Outdated
@Neerajpathak07
Copy link
Copy Markdown
Member Author

Neerajpathak07 commented Jan 2, 2026

@gururaj1512 Thanks for reviewing and flagging changes although I do have a few conflicting opinions on the description of examples!!

@Neerajpathak07 Neerajpathak07 added the JavaScript Issue involves or relates to JavaScript. label Jan 3, 2026
Comment thread lib/node_modules/@stdlib/number/float16/base/add/README.md Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/README.md Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Comment thread lib/node_modules/@stdlib/number/float16/base/add/examples/index.js Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Comment thread lib/node_modules/@stdlib/number/float16/base/add/benchmark/benchmark.js Outdated
Signed-off-by: Athan <kgryte@gmail.com>
Comment thread lib/node_modules/@stdlib/number/float16/base/add/benchmark/c/benchmark.c Outdated
t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
z = stdlib_base_float16_add( x[ i%100 ], y[ i%100 ] );
if ( z != z ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This won't work the way you need it to. You need to compare against the bit sequence value for NaN. We do this in other benchmarks for float16.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Better would be to use the eventual number/float16/base/assert/is-nan utility here.

Copy link
Copy Markdown
Member Author

@Neerajpathak07 Neerajpathak07 Mar 1, 2026

Choose a reason for hiding this comment

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

@kgryte Interesting, some of the upstream versions that I referred to such as number/float16/base/from-word, significand & to-float64. What I realized is that the JS implementation utilizes isnan() but commonly for the C benchmark we are adapting the antique if( out != out ) check.

Maybe this can we updated from here on, to utilize the nan check directly from the utilities we'll need add a C header for float16/base/assert/is-nan. If you green light this I'll get going.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It depends on the package. The reason I recommended using the utility here is that float16 is special. So it is entirely a case-by-case basis. The TL;DR is that you need to think more deeply about what is being compared and whether it is applicable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, makes more sense!!!

Comment thread lib/node_modules/@stdlib/number/float16/base/add/package.json Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/src/addon.c
Comment thread lib/node_modules/@stdlib/number/float16/base/add/test/test.js Outdated
Comment thread lib/node_modules/@stdlib/number/float16/base/add/test/test.native.js Outdated
Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

Left some initial comments.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jan 6, 2026
@Neerajpathak07
Copy link
Copy Markdown
Member Author

Will draft this PR for the time being till we add the macro and the utilities!!

@Neerajpathak07 Neerajpathak07 marked this pull request as draft January 6, 2026 03:17
@Neerajpathak07 Neerajpathak07 removed the Native Addons Issue involves or relates to Node.js native add-ons. label Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Issue involves or relates to C. Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants