-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add number/float16/base/to-float32
#9280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: add number/float16/base/to-float32
#9280
Conversation
---
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: na
- 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
---
|
/stdlib merge |
Coverage Report
The above coverage report was generated for the changes in this PR. |
---
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: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- 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
---
lib/node_modules/@stdlib/number/float16/base/to-float32/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/number/float16/base/to-float32/README.md
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <[email protected]>
lib/node_modules/@stdlib/number/float16/base/to-float32/lib/main.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/number/float16/base/to-float32/lib/native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/number/float16/base/to-float32/lib/native.js
Outdated
Show resolved
Hide resolved
| assert( status == napi_ok ); | ||
|
|
||
| float result; | ||
| result = stdlib_base_float16_to_float32( stdlib_base_float32_to_float16( (float)value ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to use float64_to_float16 here given that we are sending down a double from JavaScript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is possible. But float64 to float16 conversion would carry a lot of overhead. Infact, I am thinking of implementing float64_to_float16 as
stdlib_float16_t stdlib_base_float64_to_float16( const double value ) {
return stdlib_base_float32_to_float16( (float)value );
}In float64 to float16 conversion we have to handle both mahtissaHigh and mantissaLow this creates lot of complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. And just for sanity checking, which I think we already did, but just to triple check: float64_to_float16 === float32_to_float16 in terms of final output, correct? In which case, yes, makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did sanity check but for the JS implementation. C implementation for float64_to_float16 is not yet added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have used float64_to_float16 and this also works well here. With what approach should we move forward. According to me current approach seems more straight forward to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine to leave as is. The reality is that calling through native.js is only used for testing, so perf isn't an overriding concern. Main concern is that the two implementations are interchangeable in this particular case and return the same results.
lib/node_modules/@stdlib/number/float16/base/to-float32/src/main.c
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <[email protected]>
Signed-off-by: Athan <[email protected]>
lib/node_modules/@stdlib/number/float16/base/to-float32/src/main.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/number/float16/base/to-float32/src/main.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/number/float16/base/to-float32/src/main.c
Outdated
Show resolved
Hide resolved
kgryte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments. Otherwise, this is looking good.
---
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: na
- 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
---
|
/stdlib merge |
Resolves None
Description
This pull request:
number/float16/base/to-float32Related Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
{{TODO: add disclosure if applicable}}
@stdlib-js/reviewers