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/assert/int32-is-odd #1865

Merged
merged 8 commits into from
Mar 14, 2024
Merged

feat: add C implementation for math/base/assert/int32-is-odd #1865

merged 8 commits into from
Mar 14, 2024

Conversation

Rejoan-Sardar
Copy link
Contributor

Resolves #1806 .

Description

What is the purpose of this pull request?

This pull request:

  • add C implementation for math/base/assert/int32-is-odd

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.

  • Read, understood, and followed the [contributing guidelines][contributing].

@stdlib-js/reviewers


The function accepts the following arguments:

- **x**: `[in] long` input value.
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
- **x**: `[in] long` input value.
- **x**: `[in] int32_t` input value.

- **x**: `[in] long` input value.

```c
bool stdlib_base_int32_is_odd( const long x );
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
bool stdlib_base_int32_is_odd( const long x );
bool stdlib_base_int32_is_odd( const int32_t x );

#include <stdbool.h>

int main( void ) {
const long x[] = { 5, -5, 3, -3, 0, 0/0 };
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
const long x[] = { 5, -5, 3, -3, 0, 0/0 };
const int32_t x[] = { 5, -5, 3, -3, 0 };

#include <stdbool.h>

int main( void ) {
const long x[] = { 5, -5, 3, -3, 0, 0/0 };
Copy link
Member

@Pranavchiku Pranavchiku Mar 13, 2024

Choose a reason for hiding this comment

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

Suggested change
const long x[] = { 5, -5, 3, -3, 0, 0/0 };
const int32_t x[] = { 5, -5, 3, -3, 0 };

/**
* Tests if 32-bit integer is odd.
*/
bool stdlib_base_is_odd( const long x );
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
bool stdlib_base_is_odd( const long x );
bool stdlib_base_int32_is_odd( const int32_t x );

Comment on lines 62 to 63
long x;
status = napi_get_value_long( env, argv[ 0 ], &x );
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
long x;
status = napi_get_value_long( env, argv[ 0 ], &x );
int32_t x;
status = napi_get_value_int32( env, argv[ 0 ], &x );

Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
@Pranavchiku Pranavchiku changed the title feat: add C implementation for math/base/assert/int32-is-odd feat: add C implementation for math/base/assert/int32-is-odd Mar 13, 2024
Copy link
Member

@Pranavchiku Pranavchiku left a comment

Choose a reason for hiding this comment

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

Tested locally, everything works. Thanks @Rejoan-Sardar !

Copy link
Member

@Pranavchiku Pranavchiku left a comment

Choose a reason for hiding this comment

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

Tested locally, everything works. Thanks @Rejoan-Sardar !

@Pranavchiku Pranavchiku added Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality. Native Addons Issue involves or relates to Node.js native add-ons. C Issue involves or relates to C. Ready To Merge A pull request which is ready to be merged. labels Mar 13, 2024
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
@Planeshifter
Copy link
Member

Thanks @Rejoan-Sardar! Will merge ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Issue involves or relates to C. Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality. Native Addons Issue involves or relates to Node.js native add-ons. Ready To Merge A pull request which is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: feat: add C implementation for @stdlib/math/base/assert/int32-is-odd
3 participants