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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libm/] [math/] [s_fabs.c] - Blame information for rev 855

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
 
2
/* @(#)s_fabs.c 5.1 93/09/24 */
3
/*
4
 * ====================================================
5
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6
 *
7
 * Developed at SunPro, a Sun Microsystems, Inc. business.
8
 * Permission to use, copy, modify, and distribute this
9
 * software is freely granted, provided that this notice
10
 * is preserved.
11
 * ====================================================
12
 */
13
 
14
/*
15
FUNCTION
16
       <<fabs>>, <<fabsf>>---absolute value (magnitude)
17
INDEX
18
        fabs
19
INDEX
20
        fabsf
21
 
22
ANSI_SYNOPSIS
23
        #include <math.h>
24
       double fabs(double <[x]>);
25
       float fabsf(float <[x]>);
26
 
27
TRAD_SYNOPSIS
28
        #include <math.h>
29
       double fabs(<[x]>)
30
       double <[x]>;
31
 
32
       float fabsf(<[x]>)
33
       float <[x]>;
34
 
35
DESCRIPTION
36
<<fabs>> and <<fabsf>> calculate
37
@tex
38
$|x|$,
39
@end tex
40
the absolute value (magnitude) of the argument <[x]>, by direct
41
manipulation of the bit representation of <[x]>.
42
 
43
RETURNS
44
The calculated value is returned.  No errors are detected.
45
 
46
PORTABILITY
47
<<fabs>> is ANSI.
48
<<fabsf>> is an extension.
49
 
50
*/
51
 
52
/*
53
 * fabs(x) returns the absolute value of x.
54
 */
55
 
56
#include "fdlibm.h"
57
 
58
#ifndef _DOUBLE_IS_32BITS
59
 
60
#ifdef __STDC__
61
        double fabs(double x)
62
#else
63
        double fabs(x)
64
        double x;
65
#endif
66
{
67
        __uint32_t high;
68
        GET_HIGH_WORD(high,x);
69
        SET_HIGH_WORD(x,high&0x7fffffff);
70
        return x;
71
}
72
 
73
#endif /* _DOUBLE_IS_32BITS */

powered by: WebSVN 2.1.0

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