We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
extern crate half; use half::f16; fn main() { let plus32 = 0f32; let minus32 = -plus32; let plus16 = f16::from_f32(plus32); let minus16 = f16::from_f32(minus32); println!("plus32 == minus32 -> {}", plus32 == minus32); println!("plus16 == minus16 -> {}", plus16 == minus16); println!("plus32.partial_cmp(&minus32) -> {:?}", plus32.partial_cmp(&minus32)); println!("plus16.partial_cmp(&minus16) -> {:?}", plus16.partial_cmp(&minus16)); }
Output:
plus32 == minus32 -> true plus16 == minus16 -> false plus32.partial_cmp(&minus32) -> Some(Equal) plus16.partial_cmp(&minus16) -> Some(Less)
The text was updated successfully, but these errors were encountered:
Also, partial_cmp incorrectly just compares the inner u16, so all positive numbers are treated as less than all negative numbers.
partial_cmp
u16
Sorry, something went wrong.
is_sign_positive
No branches or pull requests
Output:
The text was updated successfully, but these errors were encountered: