Back to index

glibc  2.9
s_logbl.c
Go to the documentation of this file.
00001 /* s_logbl.c -- long double version of s_logb.c.
00002  * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz.
00003  */
00004 
00005 /*
00006  * ====================================================
00007  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00008  *
00009  * Developed at SunPro, a Sun Microsystems, Inc. business.
00010  * Permission to use, copy, modify, and distribute this
00011  * software is freely granted, provided that this notice
00012  * is preserved.
00013  * ====================================================
00014  */
00015 
00016 #if defined(LIBM_SCCS) && !defined(lint)
00017 static char rcsid[] = "$NetBSD: $";
00018 #endif
00019 
00020 /*
00021  * long double logbl(x)
00022  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
00023  * Use ilogb instead.
00024  */
00025 
00026 #include "math.h"
00027 #include "math_private.h"
00028 #include <math_ldbl_opt.h>
00029 
00030 #ifdef __STDC__
00031        long double __logbl(long double x)
00032 #else
00033        long double __logbl(x)
00034        long double x;
00035 #endif
00036 {
00037        int64_t lx,hx;
00038        GET_LDOUBLE_WORDS64(hx,lx,x);
00039        hx &= 0x7fffffffffffffffLL;        /* high |x| */
00040        if((hx|(lx&0x7fffffffffffffffLL))==0) return -1.0/fabs(x);
00041        if(hx>=0x7ff0000000000000LL) return x*x;
00042        if((hx>>=52)==0)                   /* IEEE 754 logb */
00043               return -1022.0;
00044        else
00045               return (long double) (hx-0x3ff);
00046 }
00047 long_double_symbol (libm, __logbl, logbl);