Last change
on this file was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.2 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 | SYNOPSIS |
---|
23 | #include <math.h> |
---|
24 | double fabs(double <[x]>); |
---|
25 | float fabsf(float <[x]>); |
---|
26 | |
---|
27 | DESCRIPTION |
---|
28 | <<fabs>> and <<fabsf>> calculate |
---|
29 | @tex |
---|
30 | $|x|$, |
---|
31 | @end tex |
---|
32 | the absolute value (magnitude) of the argument <[x]>, by direct |
---|
33 | manipulation of the bit representation of <[x]>. |
---|
34 | |
---|
35 | RETURNS |
---|
36 | The calculated value is returned. No errors are detected. |
---|
37 | |
---|
38 | PORTABILITY |
---|
39 | <<fabs>> is ANSI. |
---|
40 | <<fabsf>> is an extension. |
---|
41 | |
---|
42 | */ |
---|
43 | |
---|
44 | /* |
---|
45 | * fabs(x) returns the absolute value of x. |
---|
46 | */ |
---|
47 | |
---|
48 | #include "fdlibm.h" |
---|
49 | |
---|
50 | #ifndef _DOUBLE_IS_32BITS |
---|
51 | |
---|
52 | #ifdef __STDC__ |
---|
53 | double fabs(double x) |
---|
54 | #else |
---|
55 | double fabs(x) |
---|
56 | double x; |
---|
57 | #endif |
---|
58 | { |
---|
59 | __uint32_t high; |
---|
60 | GET_HIGH_WORD(high,x); |
---|
61 | SET_HIGH_WORD(x,high&0x7fffffff); |
---|
62 | return x; |
---|
63 | } |
---|
64 | |
---|
65 | #endif /* _DOUBLE_IS_32BITS */ |
---|
Note: See
TracBrowser
for help on using the repository browser.