float copysign1(float x, float y) { bool t = __builtin_signbit(x) == 0; bool t1 = __builtin_signbit(y) == 0; return (t == t1) ? y : -y; } float copysign2(float x, float y) { bool t = __builtin_signbit(x) != 0; bool t1 = __builtin_signbit(y) != 0; return (t == t1) ? y : -y; } float copysign3(float x, float y) { bool t = __builtin_signbit(x) != 0; bool t1 = __builtin_signbit(y) == 0; return (t != t1) ? y : -y; } float copysign4(float x, float y) { bool t = __builtin_signbit(x) == 0; bool t1 = __builtin_signbit(y) != 0; return (t != t1) ? y : -y; } float copysign5(float x, float y) { return __builtin_copysignf(x, y); } These all should end up being the same code. Hopefully I didn't mess these up.
Mine.