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 long double by Ulrich Drepper,
00003  * Cygnus Support, drepper@cygnus.com.
00004  */
00005 
00006 /*
00007  * ====================================================
00008  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00009  *
00010  * Developed at SunPro, a Sun Microsystems, Inc. business.
00011  * Permission to use, copy, modify, and distribute this
00012  * software is freely granted, provided that this notice
00013  * is preserved.
00014  * ====================================================
00015  */
00016 
00017 #if defined(LIBM_SCCS) && !defined(lint)
00018 static char rcsid[] = "$NetBSD: $";
00019 #endif
00020 
00021 /*
00022  * long double logbl(x)
00023  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
00024  * Use ilogb instead.
00025  */
00026 
00027 #include "math.h"
00028 #include "math_private.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        int32_t es,lx,ix;
00038        GET_LDOUBLE_WORDS(es,ix,lx,x);
00039        es &= 0x7fff;                      /* exponent */
00040        if((es|ix|lx)==0) return -1.0/fabs(x);
00041        if(es==0x7fff) return x*x;
00042        if(es==0)                   /* IEEE 754 logb */
00043               return -16382.0;
00044        else
00045               return (long double) (es-0x3fff);
00046 }
00047 weak_alias (__logbl, logbl)