-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
f64::from(bool) and f32::from(bool) #74015
Comments
Funny enough, the people are aware of this problem:
I think there's a valid reason for this, but let's see |
Integer casts are essentially no-ops since the bit pattern is the same, but casting to a float would be less obvious/straightforward, IMO. I guess you expect 1.0 as the result, same as casting through an integer gets you? |
I expect f64::from(bool) to have about the same semantics of f64::from(u32::from(bool)), yes. |
Which zero to return? |
The same as f32::from(0_u8), that should be a +0.0. |
Doc says it's implemented, so this should be closed? But what the actual hell?! |
This should be closed now, yes. Implementation PR was #100390. |
I think
f64::from(bool)
andf32::from(bool)
could be added. Currently I perform that in two steps:f64::from(u32::from(bool))
f32::from(u16::from(bool))
The text was updated successfully, but these errors were encountered: