13a8617a8SJordan K. Hubbard /* s_logbf.c -- float version of s_logb.c.
23a8617a8SJordan K. Hubbard * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
33a8617a8SJordan K. Hubbard */
43a8617a8SJordan K. Hubbard
53a8617a8SJordan K. Hubbard /*
63a8617a8SJordan K. Hubbard * ====================================================
73a8617a8SJordan K. Hubbard * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
83a8617a8SJordan K. Hubbard *
93a8617a8SJordan K. Hubbard * Developed at SunPro, a Sun Microsystems, Inc. business.
103a8617a8SJordan K. Hubbard * Permission to use, copy, modify, and distribute this
113a8617a8SJordan K. Hubbard * software is freely granted, provided that this notice
123a8617a8SJordan K. Hubbard * is preserved.
133a8617a8SJordan K. Hubbard * ====================================================
143a8617a8SJordan K. Hubbard */
153a8617a8SJordan K. Hubbard
163a8617a8SJordan K. Hubbard #include "math.h"
173a8617a8SJordan K. Hubbard #include "math_private.h"
183a8617a8SJordan K. Hubbard
1900b1756bSBruce Evans static const float
2000b1756bSBruce Evans two25 = 3.355443200e+07; /* 0x4c000000 */
2100b1756bSBruce Evans
2259b19ff1SAlfred Perlstein float
logbf(float x)2359b19ff1SAlfred Perlstein logbf(float x)
243a8617a8SJordan K. Hubbard {
253a8617a8SJordan K. Hubbard int32_t ix;
263a8617a8SJordan K. Hubbard GET_FLOAT_WORD(ix,x);
273a8617a8SJordan K. Hubbard ix &= 0x7fffffff; /* high |x| */
283a8617a8SJordan K. Hubbard if(ix==0) return (float)-1.0/fabsf(x);
293a8617a8SJordan K. Hubbard if(ix>=0x7f800000) return x*x;
3000b1756bSBruce Evans if(ix<0x00800000) {
3100b1756bSBruce Evans x *= two25; /* convert subnormal x to normal */
3200b1756bSBruce Evans GET_FLOAT_WORD(ix,x);
3300b1756bSBruce Evans ix &= 0x7fffffff;
3400b1756bSBruce Evans return (float) ((ix>>23)-127-25);
3500b1756bSBruce Evans } else
3600b1756bSBruce Evans return (float) ((ix>>23)-127);
373a8617a8SJordan K. Hubbard }
38