OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libm/] [math/] [w_acos.c] - Diff between revs 1010 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
 
 
/* @(#)w_acos.c 5.1 93/09/24 */
/* @(#)w_acos.c 5.1 93/09/24 */
/*
/*
 * ====================================================
 * ====================================================
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 *
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * software is freely granted, provided that this notice
 * is preserved.
 * is preserved.
 * ====================================================
 * ====================================================
 */
 */
 
 
/*
/*
FUNCTION
FUNCTION
        <<acos>>, <<acosf>>---arc cosine
        <<acos>>, <<acosf>>---arc cosine
 
 
INDEX
INDEX
        acos
        acos
INDEX
INDEX
        acosf
        acosf
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <math.h>
        #include <math.h>
        double acos(double <[x]>);
        double acos(double <[x]>);
        float acosf(float <[x]>);
        float acosf(float <[x]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <math.h>
        #include <math.h>
        double acos(<[x]>)
        double acos(<[x]>)
        double <[x]>;
        double <[x]>;
 
 
        float acosf(<[x]>)
        float acosf(<[x]>)
        float <[x]>;
        float <[x]>;
 
 
 
 
 
 
DESCRIPTION
DESCRIPTION
 
 
        <<acos>> computes the inverse cosine (arc cosine) of the input value.
        <<acos>> computes the inverse cosine (arc cosine) of the input value.
        Arguments to <<acos>> must be in the range @minus{}1 to 1.
        Arguments to <<acos>> must be in the range @minus{}1 to 1.
 
 
        <<acosf>> is identical to <<acos>>, except that it performs
        <<acosf>> is identical to <<acos>>, except that it performs
        its calculations on <<floats>>.
        its calculations on <<floats>>.
 
 
RETURNS
RETURNS
        @ifinfo
        @ifinfo
        <<acos>> and <<acosf>> return values in radians, in the range of 0 to pi.
        <<acos>> and <<acosf>> return values in radians, in the range of 0 to pi.
        @end ifinfo
        @end ifinfo
        @tex
        @tex
        <<acos>> and <<acosf>> return values in radians, in the range of <<0>> to $\pi$.
        <<acos>> and <<acosf>> return values in radians, in the range of <<0>> to $\pi$.
        @end tex
        @end tex
 
 
        If <[x]> is not between @minus{}1 and 1, the returned value is NaN
        If <[x]> is not between @minus{}1 and 1, the returned value is NaN
        (not a number) the global variable <<errno>> is set to <<EDOM>>, and a
        (not a number) the global variable <<errno>> is set to <<EDOM>>, and a
        <<DOMAIN error>> message is sent as standard error output.
        <<DOMAIN error>> message is sent as standard error output.
 
 
        You can modify error handling for these functions using <<matherr>>.
        You can modify error handling for these functions using <<matherr>>.
 
 
 
 
QUICKREF ANSI SVID POSIX RENTRANT
QUICKREF ANSI SVID POSIX RENTRANT
 acos    y,y,y,m
 acos    y,y,y,m
 acosf   n,n,n,m
 acosf   n,n,n,m
 
 
MATHREF
MATHREF
 acos, [-1,1], acos(arg),,,
 acos, [-1,1], acos(arg),,,
 acos, NAN,    arg,DOMAIN,EDOM
 acos, NAN,    arg,DOMAIN,EDOM
 
 
MATHREF
MATHREF
 acosf, [-1,1], acosf(arg),,,
 acosf, [-1,1], acosf(arg),,,
 acosf, NAN,    argf,DOMAIN,EDOM
 acosf, NAN,    argf,DOMAIN,EDOM
 
 
*/
*/
 
 
/*
/*
 * wrap_acos(x)
 * wrap_acos(x)
 */
 */
 
 
#include "fdlibm.h"
#include "fdlibm.h"
#include <errno.h>
#include <errno.h>
 
 
#ifndef _DOUBLE_IS_32BITS
#ifndef _DOUBLE_IS_32BITS
 
 
#ifdef __STDC__
#ifdef __STDC__
        double acos(double x)           /* wrapper acos */
        double acos(double x)           /* wrapper acos */
#else
#else
        double acos(x)                  /* wrapper acos */
        double acos(x)                  /* wrapper acos */
        double x;
        double x;
#endif
#endif
{
{
#ifdef _IEEE_LIBM
#ifdef _IEEE_LIBM
        return __ieee754_acos(x);
        return __ieee754_acos(x);
#else
#else
        double z;
        double z;
        struct exception exc;
        struct exception exc;
        z = __ieee754_acos(x);
        z = __ieee754_acos(x);
        if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
        if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
        if(fabs(x)>1.0) {
        if(fabs(x)>1.0) {
            /* acos(|x|>1) */
            /* acos(|x|>1) */
            exc.type = DOMAIN;
            exc.type = DOMAIN;
            exc.name = "acos";
            exc.name = "acos";
            exc.err = 0;
            exc.err = 0;
            exc.arg1 = exc.arg2 = x;
            exc.arg1 = exc.arg2 = x;
            exc.retval = 0.0;
            exc.retval = 0.0;
            if (_LIB_VERSION == _POSIX_)
            if (_LIB_VERSION == _POSIX_)
               errno = EDOM;
               errno = EDOM;
            else if (!matherr(&exc)) {
            else if (!matherr(&exc)) {
               errno = EDOM;
               errno = EDOM;
            }
            }
            if (exc.err != 0)
            if (exc.err != 0)
               errno = exc.err;
               errno = exc.err;
            return exc.retval;
            return exc.retval;
        } else
        } else
            return z;
            return z;
#endif
#endif
}
}
 
 
#endif /* defined(_DOUBLE_IS_32BITS) */
#endif /* defined(_DOUBLE_IS_32BITS) */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.