s_logbf.c revision 97413
1177633Sdfr/* s_logbf.c -- float version of s_logb.c.
2177633Sdfr * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3177633Sdfr */
4177633Sdfr
5177633Sdfr/*
6177633Sdfr * ====================================================
7177633Sdfr * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8177633Sdfr *
9177633Sdfr * Developed at SunPro, a Sun Microsystems, Inc. business.
10177633Sdfr * Permission to use, copy, modify, and distribute this
11177633Sdfr * software is freely granted, provided that this notice
12177633Sdfr * is preserved.
13177633Sdfr * ====================================================
14177633Sdfr */
15177633Sdfr
16177633Sdfr#ifndef lint
17177633Sdfrstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/s_logbf.c 97413 2002-05-28 18:15:04Z alfred $";
18177633Sdfr#endif
19177633Sdfr
20177633Sdfr#include "math.h"
21177633Sdfr#include "math_private.h"
22177633Sdfr
23177633Sdfrfloat
24177633Sdfrlogbf(float x)
25177633Sdfr{
26177633Sdfr	int32_t ix;
27177633Sdfr	GET_FLOAT_WORD(ix,x);
28177633Sdfr	ix &= 0x7fffffff;			/* high |x| */
29177633Sdfr	if(ix==0) return (float)-1.0/fabsf(x);
30177633Sdfr	if(ix>=0x7f800000) return x*x;
31177633Sdfr	if((ix>>=23)==0) 			/* IEEE 754 logb */
32177633Sdfr		return -126.0;
33177633Sdfr	else
34177633Sdfr		return (float) (ix-127);
35177633Sdfr}
36177633Sdfr