Use FP_ILOGB0 and FP_ILOGBNAN
This commit is contained in:
parent
afdc807ef9
commit
9074d59336
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBM_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: s_ilogb.c,v 1.13 2011/07/28 22:32:29 joerg Exp $");
|
||||
__RCSID("$NetBSD: s_ilogb.c,v 1.14 2013/02/09 22:56:00 matt Exp $");
|
||||
#endif
|
||||
|
||||
/* ilogb(double x)
|
||||
|
@ -38,7 +38,7 @@ ilogb(double x)
|
|||
if(hx<0x00100000) {
|
||||
GET_LOW_WORD(lx,x);
|
||||
if((hx|lx)==0)
|
||||
return 0x80000001; /* ilogb(0) = 0x80000001 */
|
||||
return FP_ILOGB0; /* ilogb(0) = 0x80000001 */
|
||||
else /* subnormal x */
|
||||
if(hx==0) {
|
||||
for (ix = -1043; lx>0; lx<<=1) ix -=1;
|
||||
|
@ -48,5 +48,5 @@ ilogb(double x)
|
|||
return ix;
|
||||
}
|
||||
else if (hx<0x7ff00000) return (hx>>20)-1023;
|
||||
else return 0x7fffffff;
|
||||
else return FP_ILOGBNAN; /* inf too */
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBM_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: s_ilogbf.c,v 1.7 2002/05/26 22:01:56 wiz Exp $");
|
||||
__RCSID("$NetBSD: s_ilogbf.c,v 1.8 2013/02/09 22:56:00 matt Exp $");
|
||||
#endif
|
||||
|
||||
#include "math.h"
|
||||
|
@ -30,11 +30,11 @@ ilogbf(float x)
|
|||
hx &= 0x7fffffff;
|
||||
if(hx<0x00800000) {
|
||||
if(hx==0)
|
||||
return 0x80000001; /* ilogb(0) = 0x80000001 */
|
||||
return FP_ILOGB0; /* ilogb(0) = 0x80000001 */
|
||||
else /* subnormal x */
|
||||
for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1;
|
||||
return ix;
|
||||
}
|
||||
else if (hx<0x7f800000) return (hx>>23)-127;
|
||||
else return 0x7fffffff;
|
||||
else return FP_ILOGBNAN; /* inf too */
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: s_ilogbl.c,v 1.1 2011/07/28 22:32:29 joerg Exp $ */
|
||||
/* $NetBSD: s_ilogbl.c,v 1.2 2013/02/09 22:56:00 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: s_ilogbl.c,v 1.1 2011/07/28 22:32:29 joerg Exp $");
|
||||
__RCSID("$NetBSD: s_ilogbl.c,v 1.2 2013/02/09 22:56:00 matt Exp $");
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
|
@ -54,12 +54,12 @@ ilogbl(long double x)
|
|||
union ieee_ext_u u;
|
||||
|
||||
if (x == 0.0L)
|
||||
return 0x80000001; /* ilogbl(0) = 0x80000001 */
|
||||
return FP_ILOGB0; /* ilogbl(0) = 0x80000001 */
|
||||
|
||||
u.extu_ld = x;
|
||||
|
||||
if (u.extu_ext.ext_exp == EXT_EXP_INFNAN)
|
||||
return 0x7fffffff;
|
||||
return FP_ILOGBNAN; /* inf too */
|
||||
|
||||
if (u.extu_ext.ext_exp == 0) {
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue