summaryrefslogtreecommitdiff
path: root/src/math/copysign.c
blob: 038b8b4c46beed6c2065982a56ede5ddcab16da6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
#include "libm.h"

double copysign(double x, double y) {
	union dshape ux, uy;

	ux.value = x;
	uy.value = y;
	ux.bits &= (uint64_t)-1>>1;
	ux.bits |= uy.bits & (uint64_t)1<<63;
	return ux.value;
}