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$");
182116Sjkh
192116Sjkh#include "math.h"
202116Sjkh#include "math_private.h"
212116Sjkh
222116Sjkhstatic const float one = 1.0, huge = 1e30;
232116Sjkh
242116Sjkhstatic const float zero = 0.0;
252116Sjkh
2697407Salfredfloat
2797407Salfred__ieee754_atanhf(float x)
282116Sjkh{
292116Sjkh	float t;
302116Sjkh	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);
358870Srgrimes	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));
428870Srgrimes	} else
432116Sjkh	    t = (float)0.5*log1pf((x+x)/(one-x));
442116Sjkh	if(hx>=0) return t; else return -t;
452116Sjkh}
46