Skip to content

%intoffloat converts Infinity and NaN to 0 #6038

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

Closed
glennsl opened this issue Mar 5, 2023 · 1 comment
Closed

%intoffloat converts Infinity and NaN to 0 #6038

glennsl opened this issue Mar 5, 2023 · 1 comment

Comments

@glennsl
Copy link
Contributor

glennsl commented Mar 5, 2023

This caught me by surprise. I expected it would raise an exception, similar to div by zero.

Is this behavior correct? If so, what is the rationale for it?

Repro:

int_of_float(infinity)
// or
int_of_float(nan)
@glennsl
Copy link
Contributor Author

glennsl commented Apr 21, 2024

I suppose the rationale can be given by the conversion function defined by EMCA-262 (i.e. The JavaScript language specification). This seems like the most natural and likely most performant conversion, given ReScript's goal of seamless integration with JavaScript.

I'll consider the issue resolved based on this.

@glennsl glennsl closed this as completed Apr 21, 2024
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

No branches or pull requests

1 participant