cosmopolitan/libc/math/copysign.c

9 lines
174 B
C
Raw Permalink Normal View History

2020-06-15 14:18:57 +00:00
#include "libc/math/libm.h"
double copysign(double x, double y) {
union {double f; uint64_t i;} ux={x}, uy={y};
ux.i &= -1ULL/2;
ux.i |= uy.i & 1ULL<<63;
return ux.f;
}