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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libm/] [mathfp/] [s_fabs.c] - Diff between revs 148 and 158

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

Rev 148 Rev 158
 
 
/* @(#)z_fabs.c 1.0 98/08/13 */
/* @(#)z_fabs.c 1.0 98/08/13 */
 
 
/*
/*
FUNCTION
FUNCTION
       <<fabs>>, <<fabsf>>---absolute value (magnitude)
       <<fabs>>, <<fabsf>>---absolute value (magnitude)
INDEX
INDEX
        fabs
        fabs
INDEX
INDEX
        fabsf
        fabsf
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <math.h>
        #include <math.h>
       double fabs(double <[x]>);
       double fabs(double <[x]>);
       float fabsf(float <[x]>);
       float fabsf(float <[x]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <math.h>
        #include <math.h>
       double fabs(<[x]>)
       double fabs(<[x]>)
       double <[x]>;
       double <[x]>;
 
 
       float fabsf(<[x]>)
       float fabsf(<[x]>)
       float <[x]>;
       float <[x]>;
 
 
DESCRIPTION
DESCRIPTION
<<fabs>> and <<fabsf>> calculate
<<fabs>> and <<fabsf>> calculate
@tex
@tex
$|x|$,
$|x|$,
@end tex
@end tex
the absolute value (magnitude) of the argument <[x]>, by direct
the absolute value (magnitude) of the argument <[x]>, by direct
manipulation of the bit representation of <[x]>.
manipulation of the bit representation of <[x]>.
 
 
RETURNS
RETURNS
The calculated value is returned.
The calculated value is returned.
 
 
PORTABILITY
PORTABILITY
<<fabs>> is ANSI.
<<fabs>> is ANSI.
<<fabsf>> is an extension.
<<fabsf>> is an extension.
 
 
*/
*/
 
 
/******************************************************************
/******************************************************************
 * Floating-Point Absolute Value
 * Floating-Point Absolute Value
 *
 *
 * Input:
 * Input:
 *   x - floating-point number
 *   x - floating-point number
 *
 *
 * Output:
 * Output:
 *   absolute value of x
 *   absolute value of x
 *
 *
 * Description:
 * Description:
 *   fabs computes the absolute value of a floating point number.
 *   fabs computes the absolute value of a floating point number.
 *
 *
 *****************************************************************/
 *****************************************************************/
 
 
#include "fdlibm.h"
#include "fdlibm.h"
#include "zmath.h"
#include "zmath.h"
 
 
#ifndef _DOUBLE_IS_32BITS
#ifndef _DOUBLE_IS_32BITS
 
 
double
double
_DEFUN (fabs, (double),
_DEFUN (fabs, (double),
        double x)
        double x)
{
{
  switch (numtest (x))
  switch (numtest (x))
    {
    {
      case NAN:
      case NAN:
        errno = EDOM;
        errno = EDOM;
        return (x);
        return (x);
      case INF:
      case INF:
        errno = ERANGE;
        errno = ERANGE;
        return (x);
        return (x);
      case 0:
      case 0:
        return (0.0);
        return (0.0);
      default:
      default:
        return (x < 0.0 ? -x : x);
        return (x < 0.0 ? -x : x);
    }
    }
}
}
 
 
#endif /* _DOUBLE_IS_32BITS */
#endif /* _DOUBLE_IS_32BITS */
 
 

powered by: WebSVN 2.1.0

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