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

when encountering a non-integer value, napi_get_value_int32 raises an exception instead of truncating the number #103

Closed
mmomtchev opened this issue Jan 16, 2024 · 4 comments · Fixed by #105

Comments

@mmomtchev
Copy link
Contributor

The original napi_get_value_int32 truncates floating point numbers while the emnapi version raises an exception.

I think this applies to all integer handling in emnapi.

nodejs/node-addon-api#578

@mmomtchev
Copy link
Contributor Author

I think that this happens only with emscripten

@mmomtchev
Copy link
Contributor Author

This seems to be an emscripten issue when using ASSERTIONS=2

emscripten-core/emscripten#19655

@toyobayashi
Copy link
Owner

Thanks to your investigation, I'll take a look later

@mmomtchev
Copy link
Contributor Author

There is an old JavaScript trick that is ~~value (double not), it has the effect of truncating value without (almost) any performance impact, however it does not work for 64 bit values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants