12116Sjkh/* e_acoshf.c -- float version of e_acosh.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 228870Srgrimesstatic const float 232116Sjkhone = 1.0, 242116Sjkhln2 = 6.9314718246e-01; /* 0x3f317218 */ 252116Sjkh 2697407Salfredfloat 2797407Salfred__ieee754_acoshf(float x) 288870Srgrimes{ 292116Sjkh float t; 302116Sjkh int32_t hx; 312116Sjkh GET_FLOAT_WORD(hx,x); 322116Sjkh if(hx<0x3f800000) { /* x < 1 */ 332116Sjkh return (x-x)/(x-x); 342116Sjkh } else if(hx >=0x4d800000) { /* x > 2**28 */ 352116Sjkh if(hx >=0x7f800000) { /* x is inf of NaN */ 362116Sjkh return x+x; 378870Srgrimes } else 382116Sjkh return __ieee754_logf(x)+ln2; /* acosh(huge)=log(2x) */ 392116Sjkh } else if (hx==0x3f800000) { 402116Sjkh return 0.0; /* acosh(1) = 0 */ 412116Sjkh } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ 422116Sjkh t=x*x; 4323579Sbde return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one))); 442116Sjkh } else { /* 1<x<2 */ 452116Sjkh t = x-one; 4623579Sbde return log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t)); 472116Sjkh } 482116Sjkh} 49