Changeset View
Changeset View
Standalone View
Standalone View
head/lib/msun/src/s_fmax.c
Show All 21 Lines | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <float.h> | |||||
#include <math.h> | #include <math.h> | ||||
#include "fpmath.h" | #include "fpmath.h" | ||||
double | double | ||||
fmax(double x, double y) | fmax(double x, double y) | ||||
{ | { | ||||
union IEEEd2bits u[2]; | union IEEEd2bits u[2]; | ||||
u[0].d = x; | u[0].d = x; | ||||
u[1].d = y; | u[1].d = y; | ||||
/* Check for NaNs to avoid raising spurious exceptions. */ | /* Check for NaNs to avoid raising spurious exceptions. */ | ||||
if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0) | if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0) | ||||
return (y); | return (y); | ||||
if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0) | if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0) | ||||
return (x); | return (x); | ||||
/* Handle comparisons of signed zeroes. */ | /* Handle comparisons of signed zeroes. */ | ||||
if (u[0].bits.sign != u[1].bits.sign) | if (u[0].bits.sign != u[1].bits.sign) | ||||
return (u[u[0].bits.sign].d); | return (u[u[0].bits.sign].d); | ||||
return (x > y ? x : y); | return (x > y ? x : y); | ||||
} | } | ||||
#if (LDBL_MANT_DIG == 53) | |||||
__weak_reference(fmax, fmaxl); | |||||
#endif |