Back to index

glibc  2.9
s_logbf.c
Go to the documentation of this file.
00001 /* s_logbf.c -- float version of s_logb.c.
00002  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
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: s_logbf.c,v 1.4 1995/05/10 20:47:51 jtc Exp $";
00018 #endif
00019 
00020 #include "math.h"
00021 #include "math_private.h"
00022 
00023 #ifdef __STDC__
00024        float __logbf(float x)
00025 #else
00026        float __logbf(x)
00027        float x;
00028 #endif
00029 {
00030        int32_t ix;
00031        GET_FLOAT_WORD(ix,x);
00032        ix &= 0x7fffffff;                  /* high |x| */
00033        if(ix==0) return (float)-1.0/fabsf(x);
00034        if(ix>=0x7f800000) return x*x;
00035        if((ix>>=23)==0)                   /* IEEE 754 logb */
00036               return -126.0; 
00037        else
00038               return (float) (ix-127); 
00039 }
00040 weak_alias (__logbf, logbf)