Back to index

glibc  2.9
e_atanhf.c
Go to the documentation of this file.
00001 /* e_atanhf.c -- float version of e_atanh.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: e_atanhf.c,v 1.4 1995/05/10 20:44:56 jtc Exp $";
00018 #endif
00019 
00020 #include "math.h"
00021 #include "math_private.h"
00022 
00023 #ifdef __STDC__
00024 static const float one = 1.0, huge = 1e30;
00025 #else
00026 static float one = 1.0, huge = 1e30;
00027 #endif
00028 
00029 #ifdef __STDC__
00030 static const float zero = 0.0;
00031 #else
00032 static float zero = 0.0;
00033 #endif
00034 
00035 #ifdef __STDC__
00036        float __ieee754_atanhf(float x)
00037 #else
00038        float __ieee754_atanhf(x)
00039        float x;
00040 #endif
00041 {
00042        float t;
00043        int32_t hx,ix;
00044        GET_FLOAT_WORD(hx,x);
00045        ix = hx&0x7fffffff;
00046        if (ix>0x3f800000)          /* |x|>1 */
00047            return (x-x)/(x-x);
00048        if(ix==0x3f800000) 
00049            return x/zero;
00050        if(ix<0x31800000&&(huge+x)>zero) return x;       /* x<2**-28 */
00051        SET_FLOAT_WORD(x,ix);
00052        if(ix<0x3f000000) {         /* x < 0.5 */
00053            t = x+x;
00054            t = (float)0.5*__log1pf(t+t*x/(one-x));
00055        } else 
00056            t = (float)0.5*__log1pf((x+x)/(one-x));
00057        if(hx>=0) return t; else return -t;
00058 }