src/libm/s_copysign.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 04 Nov 2017 15:53:19 -0700
changeset 11683 48bcba563d9c
parent 6044 35448a5ea044
permissions -rw-r--r--
Updated math code from the uClibc 0.9.33 release
slouken@2756
     1
/*
slouken@2756
     2
 * ====================================================
slouken@2756
     3
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
slouken@2756
     4
 *
slouken@2756
     5
 * Developed at SunPro, a Sun Microsystems, Inc. business.
slouken@2756
     6
 * Permission to use, copy, modify, and distribute this
slouken@2756
     7
 * software is freely granted, provided that this notice
slouken@2756
     8
 * is preserved.
slouken@2756
     9
 * ====================================================
slouken@2756
    10
 */
slouken@2756
    11
slouken@2756
    12
/*
slouken@2756
    13
 * copysign(double x, double y)
slouken@2756
    14
 * copysign(x,y) returns a value with the magnitude of x and
slouken@2756
    15
 * with the sign bit of y.
slouken@2756
    16
 */
slouken@2756
    17
slouken@6044
    18
#include "math_libm.h"
slouken@2756
    19
#include "math_private.h"
slouken@2756
    20
slouken@11683
    21
double copysign(double x, double y)
slouken@2756
    22
{
slouken@11683
    23
	u_int32_t hx,hy;
slouken@11683
    24
	GET_HIGH_WORD(hx,x);
slouken@11683
    25
	GET_HIGH_WORD(hy,y);
slouken@11683
    26
	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
slouken@11683
    27
        return x;
slouken@2756
    28
}
slouken@2756
    29
libm_hidden_def(copysign)