|
Last change
on this file since 1392 was 2, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 |
|
|---|
| 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 */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.