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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libm/] [math/] [w_sqrt.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
 
 
/* @(#)w_sqrt.c 5.1 93/09/24 */
/* @(#)w_sqrt.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
        <<sqrt>>, <<sqrtf>>---positive square root
        <<sqrt>>, <<sqrtf>>---positive square root
 
 
INDEX
INDEX
        sqrt
        sqrt
INDEX
INDEX
        sqrtf
        sqrtf
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <math.h>
        #include <math.h>
        double sqrt(double <[x]>);
        double sqrt(double <[x]>);
        float  sqrtf(float <[x]>);
        float  sqrtf(float <[x]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <math.h>
        #include <math.h>
        double sqrt(<[x]>);
        double sqrt(<[x]>);
        float  sqrtf(<[x]>);
        float  sqrtf(<[x]>);
 
 
DESCRIPTION
DESCRIPTION
        <<sqrt>> computes the positive square root of the argument.
        <<sqrt>> computes the positive square root of the argument.
        You can modify error handling for this function with
        You can modify error handling for this function with
        <<matherr>>.
        <<matherr>>.
 
 
RETURNS
RETURNS
        On success, the square root is returned. If <[x]> is real and
        On success, the square root is returned. If <[x]> is real and
        positive, then the result is positive.  If <[x]> is real and
        positive, then the result is positive.  If <[x]> is real and
        negative, the global value <<errno>> is set to <<EDOM>> (domain error).
        negative, the global value <<errno>> is set to <<EDOM>> (domain error).
 
 
 
 
PORTABILITY
PORTABILITY
        <<sqrt>> is ANSI C.  <<sqrtf>> is an extension.
        <<sqrt>> is ANSI C.  <<sqrtf>> is an extension.
*/
*/
 
 
/*
/*
 * wrapper sqrt(x)
 * wrapper sqrt(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 sqrt(double x)           /* wrapper sqrt */
        double sqrt(double x)           /* wrapper sqrt */
#else
#else
        double sqrt(x)                  /* wrapper sqrt */
        double sqrt(x)                  /* wrapper sqrt */
        double x;
        double x;
#endif
#endif
{
{
#ifdef _IEEE_LIBM
#ifdef _IEEE_LIBM
        return __ieee754_sqrt(x);
        return __ieee754_sqrt(x);
#else
#else
        struct exception exc;
        struct exception exc;
        double z;
        double z;
        z = __ieee754_sqrt(x);
        z = __ieee754_sqrt(x);
        if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
        if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
        if(x<0.0) {
        if(x<0.0) {
          exc.type = DOMAIN;
          exc.type = DOMAIN;
          exc.name = "sqrt";
          exc.name = "sqrt";
          exc.err = 0;
          exc.err = 0;
          exc.arg1 = exc.arg2 = x;
          exc.arg1 = exc.arg2 = x;
          if (_LIB_VERSION == _SVID_)
          if (_LIB_VERSION == _SVID_)
            exc.retval = 0.0;
            exc.retval = 0.0;
          else
          else
            exc.retval = 0.0/0.0;
            exc.retval = 0.0/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.