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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [mathfp/] [sf_fabs.c] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
2
/* @(#)z_fabsf.c 1.0 98/08/13 */
3
/******************************************************************
4
 * Floating-Point Absolute Value
5
 *
6
 * Input:
7
 *   x - floating-point number
8
 *
9
 * Output:
10
 *   absolute value of x
11
 *
12
 * Description:
13
 *   fabs computes the absolute value of a floating point number.
14
 *
15
 *****************************************************************/
16
 
17
#include "fdlibm.h"
18
#include "zmath.h"
19
 
20
float
21
_DEFUN (fabsf, (float),
22
        float x)
23
{
24
  switch (numtestf (x))
25
    {
26
      case NAN:
27
        errno = EDOM;
28
        return (x);
29
      case INF:
30
        errno = ERANGE;
31
        return (x);
32
      case 0:
33
        return (0.0);
34
      default:
35
        return (x < 0.0 ? -x : x);
36
    }
37
}
38
 
39
#ifdef _DOUBLE_IS_32BITS
40
double fabs (double x)
41
{
42
  return (double) fabsf ((float) x);
43
}
44
 
45
#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.