-
Notifications
You must be signed in to change notification settings - Fork 141
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
Document and/or allow truncation/rounding when casting from float to int? #296
Comments
Doc improvements are welcome in PRs.
That sounds like a whole new API! Maybe you could implement your own wrapper with different floating point behavior, and I found an example of that in a different crate with |
I'm currently working with For the specific issue, there's workarounds, but I think it was worth asking here since it seems to be the most natural place to change it. If you don't think it should be added though, that's fine |
This isn't generally possible to guarantee either. In any case, it's not possible to control rounding with the current API. A new rounding API would need to be proposed. |
ah yes, currently I'm doing Sounds good. I don't think I'll propose such an API myself, so for now I'll just close this. |
When casting from a float to an int, currently it follows the default approach of truncating the digits.
I think it may be worth more explicit in the docs that this is the default behavior.
In addition, for some cases it may be worth letting the caller dictate the rounding behavior, as right now in a generic context it's not possible to control how it's handled, unless I use some hacky check after conversion.
The text was updated successfully, but these errors were encountered: