Skip to content

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

Merged
Planeshifter merged 10 commits into
stdlib-js:developfrom
gunjjoshi:roundb
Jul 13, 2024
Merged

feat: add C implementation for math/base/special/roundb#2544
Planeshifter merged 10 commits into
stdlib-js:developfrom
gunjjoshi:roundb

Conversation

@gunjjoshi

@gunjjoshi gunjjoshi commented Jul 9, 2024

Copy link
Copy Markdown
Member

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

kgryte commented Jul 9, 2024

Copy link
Copy Markdown
Member

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

@gunjjoshi

Copy link
Copy Markdown
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

gunjjoshi commented Jul 9, 2024

Copy link
Copy Markdown
Member Author

@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

gunjjoshi commented Jul 9, 2024

Copy link
Copy Markdown
Member Author

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

kgryte commented Jul 9, 2024

Copy link
Copy Markdown
Member

@gunjjoshi Yes, that would be great!

@kgryte

kgryte commented Jul 9, 2024

Copy link
Copy Markdown
Member

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

@gunjjoshi

Copy link
Copy Markdown
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
Copy Markdown
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

kgryte commented Jul 9, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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

Comment thread lib/node_modules/@stdlib/math/base/special/roundb/examples/c/example.c Outdated
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>

@Planeshifter Planeshifter left a comment

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.

Thanks, @gunjjoshi! Will merge once CI passes.

@Planeshifter
Planeshifter merged commit 2e723fb into stdlib-js:develop Jul 13, 2024
@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