Last change
on this file since 466 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
719 bytes
|
Line | |
---|
1 | |
---|
2 | /* @(#)z_floorf.c 1.0 98/08/13 */ |
---|
3 | /***************************************************************** |
---|
4 | * floor |
---|
5 | * |
---|
6 | * Input: |
---|
7 | * x - floating point value |
---|
8 | * |
---|
9 | * Output: |
---|
10 | * Smallest integer less than x. |
---|
11 | * |
---|
12 | * Description: |
---|
13 | * This routine returns the smallest integer less than x. |
---|
14 | * |
---|
15 | *****************************************************************/ |
---|
16 | |
---|
17 | #include "fdlibm.h" |
---|
18 | #include "zmath.h" |
---|
19 | |
---|
20 | float |
---|
21 | floorf (float x) |
---|
22 | { |
---|
23 | float f, y; |
---|
24 | |
---|
25 | if (x > -1.0 && x < 1.0) |
---|
26 | return (x >= 0 ? 0 : -1.0); |
---|
27 | |
---|
28 | y = modff (x, &f); |
---|
29 | |
---|
30 | if (y == 0.0) |
---|
31 | return (x); |
---|
32 | |
---|
33 | return (x >= 0 ? f : f - 1.0); |
---|
34 | } |
---|
35 | |
---|
36 | #ifdef _DOUBLE_IS_32BITS |
---|
37 | double floor (double x) |
---|
38 | { |
---|
39 | return (double) floorf ((float) x); |
---|
40 | } |
---|
41 | |
---|
42 | #endif /* defined(_DOUBLE_IS_32BITS) */ |
---|
Note: See
TracBrowser
for help on using the repository browser.