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 
00029 #ifdef __STDC__
00030        long double __logbl(long double x)
00031 #else
00032        long double __logbl(x)
00033        long double x;
00034 #endif
00035 {
00036        int64_t lx,hx;
00037        GET_LDOUBLE_WORDS64(hx,lx,x);
00038        hx &= 0x7fffffffffffffffLL;        /* high |x| */
00039        if((hx|lx)==0) return -1.0/fabs(x);
00040        if(hx>=0x7fff000000000000LL) return x*x;
00041        if((hx>>=48)==0)                   /* IEEE 754 logb */
00042               return -16382.0;
00043        else
00044               return (long double) (hx-0x3fff);
00045 }
00046 weak_alias (__logbl, logbl)