Skip to content

Conversation

@gururaj1512
Copy link
Member

Resolves None.

Description

What is the purpose of this pull request?

This pull request:

  • feat: add number/float16/base/to-word

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.

Screenshot 2025-11-03 at 3 30 47 PM

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

Got the first draft of code and basic understanding by consulting ChatGPT and claude.ai. But studied the implementation from various resources


@stdlib-js/reviewers

@gururaj1512
Copy link
Member Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Nov 3, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Nov 3, 2025

Coverage Report

Package Statements Branches Functions Lines
number/float16/base/to-word $\color{red}213/231$
$color{green}+92.21%$
$\color{red}27/33$
$color{green}+81.82%$
$\color{green}1/1$
$color{green}+100.00%$
$\color{red}213/231$
$color{green}+92.21%$

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

@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Nov 3, 2025
@kgryte
Copy link
Member

kgryte commented Nov 18, 2025

/stdlib merge

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Nov 18, 2025
@kgryte kgryte added the Feature Issue or pull request for adding a new feature. label Nov 18, 2025

#### toWord( x )

Returns an unsigned 16-bit `integer` corresponding to the [IEEE 754][ieee754] binary representation of a [half-precision floating-point number][ieee754].
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
Returns an unsigned 16-bit `integer` corresponding to the [IEEE 754][ieee754] binary representation of a [half-precision floating-point number][ieee754].
Returns an unsigned 16-bit integer corresponding to the [IEEE 754][ieee754] binary representation of a [half-precision floating-point number][ieee754].

@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Nov 18, 2025

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1.0e7 ) - 5.0e6;
Copy link
Member

Choose a reason for hiding this comment

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

@gururaj1512 Would you mind updating this file to use random/array/uniform and x[ i%x.length ], so that we can avoid PRNG generation within the hot loop?

Parameters
----------
x: float
half-precision floating-point number.
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
half-precision floating-point number.
Half-precision floating-point number.


Parameters
----------
x: float
Copy link
Member

@kgryte kgryte Nov 18, 2025

Choose a reason for hiding this comment

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

Suggested change
x: float
x: number

* limitations under the License.
*/

import toWordf = require( './index' );
Copy link
Member

Choose a reason for hiding this comment

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

s/toWordf/toWord/ here and below.

Copy link
Member

Choose a reason for hiding this comment

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

@gururaj1512 Did you test whether this generated the same results as the current "main" implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

@kgryte Yaa, I have tested this implementation, and this is working as intended

@kgryte kgryte marked this pull request as ready for review November 18, 2025 11:02
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Nov 18, 2025
@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 Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants