compiler_builtins/math/libm_math/generic/
copysign.rs

1use crate::support::Float;
2
3/// Copy the sign of `y` to `x`.
4#[inline]
5pub fn copysign<F: Float>(x: F, y: F) -> F {
6    let mut ux = x.to_bits();
7    let uy = y.to_bits();
8    ux &= !F::SIGN_MASK;
9    ux |= uy & F::SIGN_MASK;
10    F::from_bits(ux)
11}