e_atanhf.c revision 256281
12116Sjkh/* e_atanhf.c -- float version of e_atanh.c.
22116Sjkh * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
32116Sjkh */
42116Sjkh
52116Sjkh/*
62116Sjkh * ====================================================
72116Sjkh * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
82116Sjkh *
92116Sjkh * Developed at SunPro, a Sun Microsystems, Inc. business.
102116Sjkh * Permission to use, copy, modify, and distribute this
118870Srgrimes * software is freely granted, provided that this notice
122116Sjkh * is preserved.
132116Sjkh * ====================================================
142116Sjkh */
152116Sjkh
16176451Sdas#include <sys/cdefs.h>
17176451Sdas__FBSDID("$FreeBSD: stable/10/lib/msun/src/e_atanhf.c 176451 2008-02-22 02:30:36Z das $");
182116Sjkh
19284810Stijl#include "math.h"
20284810Stijl#include "math_private.h"
21284810Stijl
22284810Stijlstatic const float one = 1.0, huge = 1e30;
232116Sjkh
242116Sjkhstatic const float zero = 0.0;
252116Sjkh
26284810Stijlfloat
272116Sjkh__ieee754_atanhf(float x)
28284810Stijl{
29284810Stijl	float t;
308870Srgrimes	int32_t hx,ix;
312116Sjkh	GET_FLOAT_WORD(hx,x);
322116Sjkh	ix = hx&0x7fffffff;
332116Sjkh	if (ix>0x3f800000) 		/* |x|>1 */
342116Sjkh	    return (x-x)/(x-x);
352116Sjkh	if(ix==0x3f800000)
362116Sjkh	    return x/zero;
372116Sjkh	if(ix<0x31800000&&(huge+x)>zero) return x;	/* x<2**-28 */
382116Sjkh	SET_FLOAT_WORD(x,ix);
392116Sjkh	if(ix<0x3f000000) {		/* x < 0.5 */
402116Sjkh	    t = x+x;
412116Sjkh	    t = (float)0.5*log1pf(t+t*x/(one-x));
422116Sjkh	} else
432116Sjkh	    t = (float)0.5*log1pf((x+x)/(one-x));
442116Sjkh	if(hx>=0) return t; else return -t;
452116Sjkh}
462116Sjkh