+ let result = abs(Scalar, Value(v)).0;
+ assert_eq!(expected.to_bits(), result.to_bits());
+ }
+ }
+
+ #[test]
+ #[cfg_attr(
+ not(feature = "f16"),
+ should_panic(expected = "f16 feature is not enabled")
+ )]
+ fn test_copy_sign_f16() {
+ #[track_caller]
+ fn check(mag_bits: u16, sign_bits: u16) {
+ let mag = F16::from_bits(mag_bits);
+ let sign = F16::from_bits(sign_bits);
+ let expected = mag.copysign(sign);
+ let result = copy_sign(Scalar, Value(mag), Value(sign)).0;
+ assert_eq!(expected.to_bits(), result.to_bits());
+ }
+ for mag_low_bits in 0..16 {
+ for mag_high_bits in 0..16 {
+ for sign_low_bits in 0..16 {
+ for sign_high_bits in 0..16 {
+ check(
+ mag_low_bits | (mag_high_bits << (16 - 4)),
+ sign_low_bits | (sign_high_bits << (16 - 4)),
+ );
+ }
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn test_copy_sign_f32() {
+ #[track_caller]
+ fn check(mag_bits: u32, sign_bits: u32) {
+ let mag = f32::from_bits(mag_bits);
+ let sign = f32::from_bits(sign_bits);
+ let expected = mag.copysign(sign);
+ let result = copy_sign(Scalar, Value(mag), Value(sign)).0;
+ assert_eq!(expected.to_bits(), result.to_bits());
+ }
+ for mag_low_bits in 0..16 {
+ for mag_high_bits in 0..16 {
+ for sign_low_bits in 0..16 {
+ for sign_high_bits in 0..16 {
+ check(
+ mag_low_bits | (mag_high_bits << (32 - 4)),
+ sign_low_bits | (sign_high_bits << (32 - 4)),
+ );
+ }
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn test_copy_sign_f64() {
+ #[track_caller]
+ fn check(mag_bits: u64, sign_bits: u64) {
+ let mag = f64::from_bits(mag_bits);
+ let sign = f64::from_bits(sign_bits);
+ let expected = mag.copysign(sign);
+ let result = copy_sign(Scalar, Value(mag), Value(sign)).0;