2023-09-23 16:02:42 -05:00
|
|
|
//@ run-pass
|
|
|
|
// Makes sure we use `==` (not bitwise) semantics for float comparison.
|
|
|
|
|
2024-03-26 05:01:09 -05:00
|
|
|
#![feature(f128)]
|
|
|
|
#![feature(f16)]
|
|
|
|
|
|
|
|
// FIXME(f16_f128): remove gates when ABI issues are resolved
|
|
|
|
|
|
|
|
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
|
|
|
fn check_f16() {
|
|
|
|
const F1: f16 = 0.0;
|
|
|
|
const F2: f16 = -0.0;
|
|
|
|
assert_eq!(F1, F2);
|
|
|
|
assert_ne!(F1.to_bits(), F2.to_bits());
|
|
|
|
assert!(matches!(F1, F2));
|
|
|
|
assert!(matches!(F2, F1));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_f32() {
|
2023-09-23 16:02:42 -05:00
|
|
|
const F1: f32 = 0.0;
|
|
|
|
const F2: f32 = -0.0;
|
|
|
|
assert_eq!(F1, F2);
|
|
|
|
assert_ne!(F1.to_bits(), F2.to_bits());
|
|
|
|
assert!(matches!(F1, F2));
|
|
|
|
assert!(matches!(F2, F1));
|
|
|
|
}
|
2024-03-26 05:01:09 -05:00
|
|
|
|
|
|
|
fn check_f64() {
|
|
|
|
const F1: f64 = 0.0;
|
|
|
|
const F2: f64 = -0.0;
|
|
|
|
assert_eq!(F1, F2);
|
|
|
|
assert_ne!(F1.to_bits(), F2.to_bits());
|
|
|
|
assert!(matches!(F1, F2));
|
|
|
|
assert!(matches!(F2, F1));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
|
|
|
fn check_f128() {
|
|
|
|
const F1: f128 = 0.0;
|
|
|
|
const F2: f128 = -0.0;
|
|
|
|
assert_eq!(F1, F2);
|
|
|
|
assert_ne!(F1.to_bits(), F2.to_bits());
|
|
|
|
assert!(matches!(F1, F2));
|
|
|
|
assert!(matches!(F2, F1));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
|
|
|
check_f16();
|
|
|
|
check_f32();
|
|
|
|
check_f64();
|
|
|
|
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
|
|
|
check_f128();
|
|
|
|
}
|