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

Add parameter to scalar conversion functions specifying overflow behavior #3066

Closed
wolffcm opened this issue Jul 31, 2020 · 1 comment
Closed

Comments

@wolffcm
Copy link

wolffcm commented Jul 31, 2020

Currently our conversion functions like int(), uint() will silently give a wrong answer if you try to convert a value that does not fit into the destination type. Here's an example:

$ flux repl
> uint(v: -1)
18446744073709551615

We should add a parameter to these functions that specify what to do if the input value does not fit. By default we can keep the current behavior. Here's a possible way to do it:

$ flux repl
> uint(v: -1, errOnOverflow: true)
Error: cannot represent value -1 as an uint

DOD: numeric conversion functions provide a way to error on overflow, and have related tests

Copy link

This issue has had no recent activity and will be closed soon.

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

No branches or pull requests

1 participant