-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add number/float16/base/signbit
#9390
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/signbit
#9390
Conversation
|
/stdlib update-copyright-years |
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
Given that Repl error is not caused to know changes related to this PR hence I'll go ahead and open this for Review! |
| bool = signbit( toFloat16( -5.960464477539063e-8 ) ); | ||
| // returns true |
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.
testing against float16/smallest-subnormal val to test underflow and bit-level correctness.
As it is the smallest non-zero magnitude number that still carries a sign bit.
| // Shift off all bits which are not the sign bit and check if the sign bit is on: | ||
| return ( w >>> 15 ) ? true : false; // eslint-disable-line no-unneeded-ternary |
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.
Since toWord converts to an unsigned 16-bit integer returning the values after shift off all bits is why I went with using 15. Also to make sure the number bits do not overflow.
Resolves none.
Description
This pull request:
number/float16/base/signbitRelated 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