Back to index

glibc  2.9
e_acoshf.c
Go to the documentation of this file.
00001 /* e_acoshf.c -- float version of e_acosh.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_acoshf.c,v 1.5 1995/05/12 04:57:20 jtc Exp $";
00018 #endif
00019 
00020 #include "math.h"
00021 #include "math_private.h"
00022 
00023 #ifdef __STDC__
00024 static const float 
00025 #else
00026 static float 
00027 #endif
00028 one    = 1.0,
00029 ln2    = 6.9314718246e-01;  /* 0x3f317218 */
00030 
00031 #ifdef __STDC__
00032        float __ieee754_acoshf(float x)
00033 #else
00034        float __ieee754_acoshf(x)
00035        float x;
00036 #endif
00037 {      
00038        float t;
00039        int32_t hx;
00040        GET_FLOAT_WORD(hx,x);
00041        if(hx<0x3f800000) {         /* x < 1 */
00042            return (x-x)/(x-x);
00043        } else if(hx >=0x4d800000) {       /* x > 2**28 */
00044            if(hx >=0x7f800000) {   /* x is inf of NaN */
00045                return x+x;
00046            } else 
00047               return __ieee754_logf(x)+ln2;      /* acosh(huge)=log(2x) */
00048        } else if (hx==0x3f800000) {
00049            return 0.0;                    /* acosh(1) = 0 */
00050        } else if (hx > 0x40000000) {      /* 2**28 > x > 2 */
00051            t=x*x;
00052            return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one)));
00053        } else {                    /* 1<x<2 */
00054            t = x-one;
00055            return __log1pf(t+__sqrtf((float)2.0*t+t*t));
00056        }
00057 }