mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 06:43:20 +03:00
8840409f7a
There are a number of instances of `FIXME(f16_f128)` related to target configuration; either these could use `target_has_reliable_f128`, or the FIXME is describing such a cfg and is thus redundant (since any `cfg(target_has_reliable_f*)` needs to be removed before stabilization anyway). Switch to using `target_has_reliable_*` where applicable and remove the redundant FIXMEs.
55 lines
1.3 KiB
Rust
55 lines
1.3 KiB
Rust
//@ run-pass
|
|
//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f128)
|
|
// Makes sure we use `==` (not bitwise) semantics for float comparison.
|
|
|
|
#![feature(cfg_target_has_reliable_f16_f128)]
|
|
#![feature(f128)]
|
|
#![feature(f16)]
|
|
|
|
#[cfg(target_has_reliable_f16)]
|
|
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() {
|
|
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));
|
|
}
|
|
|
|
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(target_has_reliable_f128)]
|
|
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(target_has_reliable_f16)]
|
|
check_f16();
|
|
check_f32();
|
|
check_f64();
|
|
#[cfg(target_has_reliable_f128)]
|
|
check_f128();
|
|
}
|