Last change
on this file since 503 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
812 bytes
|
Line | |
---|
1 | |
---|
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 | fabsf (float x) |
---|
22 | { |
---|
23 | switch (numtestf (x)) |
---|
24 | { |
---|
25 | case NAN: |
---|
26 | errno = EDOM; |
---|
27 | return (x); |
---|
28 | case INF: |
---|
29 | errno = ERANGE; |
---|
30 | return (x); |
---|
31 | case 0: |
---|
32 | return (0.0); |
---|
33 | default: |
---|
34 | return (x < 0.0 ? -x : x); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | #ifdef _DOUBLE_IS_32BITS |
---|
39 | double fabs (double x) |
---|
40 | { |
---|
41 | return (double) fabsf ((float) x); |
---|
42 | } |
---|
43 | |
---|
44 | #endif /* defined(_DOUBLE_IS_32BITS) */ |
---|
Note: See
TracBrowser
for help on using the repository browser.