Skip to content
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

feat: add C implementation for math/base/special/roundb #2544

Merged
merged 10 commits into from
Jul 13, 2024

Conversation

gunjjoshi
Copy link
Member

@gunjjoshi gunjjoshi commented Jul 9, 2024

Description

What is the purpose of this pull request?

This pull request:

double stdlib_base_roundb( const double x, const double n, const double b );

Related Issues

Does this pull request have any related issues?

This pull request:

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.


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added the Math Issue or pull request specific to math functionality. label Jul 9, 2024
@kgryte
Copy link
Member

kgryte commented Jul 9, 2024

@gunjjoshi Would it make more sense to make n and b 32-bit integers, similar to n in roundn?

@gunjjoshi
Copy link
Member Author

@gunjjoshi Would it make more sense to make n and b 32-bit integers, similar to n in roundn?

Sure @kgryte, I will change that.

@gunjjoshi
Copy link
Member Author

gunjjoshi commented Jul 9, 2024

@kgryte, Do we have STDLIB_MATH_BASE_NAPI_MODULE_DII_D( stdlib_base_roundb )? Or should we use something else here?

Edit: checked it, we don't have this.

@gunjjoshi
Copy link
Member Author

gunjjoshi commented Jul 9, 2024

Should I add napi_value stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) ) in math/base/napi/ternary/src/main.c in a seperate PR?
And then we can use it here.

@kgryte
Copy link
Member

kgryte commented Jul 9, 2024

@gunjjoshi Yes, that would be great!

@kgryte
Copy link
Member

kgryte commented Jul 9, 2024

I believe you'll also need to add a corresponding macro to that same package.

@gunjjoshi
Copy link
Member Author

Yes. I'll add the macro in the .h file as well.

kgryte added a commit that referenced this pull request Jul 9, 2024
PR-URL: #2546
Ref: #2544
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com> 
Signed-off-by: Athan Reines <kgryte@gmail.com>
@gunjjoshi
Copy link
Member Author

@kgryte Our math/base/assert/is-nan and math/base/assert/is-infinite take double as input. But we have 2 integer values, n and b to handle here. We have some test cases which fail due to this. I checked roundn, but over there, we do not have test cases which give NaN or +-infinite as the arguments for the integer n.

@kgryte
Copy link
Member

kgryte commented Jul 9, 2024

As discussed offline, the plan here is to remove non-applicable tests for the native bindings for n and b with regard to the C implementation and its restriction to only accept integer arguments.

Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com>
Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com>
Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com>
Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com>
Signed-off-by: GUNJ JOSHI <gunjjoshi8372@gmail.com>
@gunjjoshi
Copy link
Member Author

I have also removed the checks in main.c where we check if b or n is NaN or infinite.

Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

Thanks, @gunjjoshi! Will merge once CI passes.

@Planeshifter Planeshifter merged commit 2e723fb into stdlib-js:develop Jul 13, 2024
8 checks passed
@gunjjoshi gunjjoshi deleted the roundb branch August 21, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Math Issue or pull request specific to math functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants