stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

[RFC]: add C implementation for `number/uint32/base/to-int32`

Open gunjjoshi opened this issue 1 year ago • 6 comments

Description

This RFC proposes adding C implementation for number/uint32/base/to-int32.

This is a pre-requisite for the C implementation of stdlib/math/base/special/pow.

Related Issues

Related issues #649.

Questions

No.

Other

No.

Checklist

  • [X] I have read and understood the Code of Conduct.
  • [X] Searched for existing issues and pull requests.
  • [X] The issue name begins with RFC:.

gunjjoshi avatar Mar 16 '24 11:03 gunjjoshi

What can be a suitable function signature for this ? cc: @kgryte

gunjjoshi avatar Mar 16 '24 11:03 gunjjoshi

@gunjjoshi FYI: pow is already in-flight. See https://github.com/stdlib-js/stdlib/pull/1739.

kgryte avatar Mar 16 '24 12:03 kgryte

Thanks for pointing this out @kgryte. We can close this issue then.

gunjjoshi avatar Mar 16 '24 12:03 gunjjoshi

I'm not sure this implementation is strictly necessary atm. In C, one can simply do

uint32_t v1 = 4;

// ...

int32_t v2 = (int32_t)v1;

We added the JS package to provide a functional API for "casting", given that JS does not have static types, as in C.

Nevertheless, I think we can keep this open, but this is not high priority and we can revisit later on.

kgryte avatar Mar 16 '24 12:03 kgryte

Sounds good. Thanks for explaining this.

gunjjoshi avatar Mar 16 '24 12:03 gunjjoshi

i want to work on this issue, if it has not been assigned to someone.

Akshat-Kob avatar Apr 02 '24 09:04 Akshat-Kob