source: trunk/libs/newlib/src/newlib/libm/mathfp/sf_ceil.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 730 bytes
Line 
1
2/* @(#)z_ceilf.c 1.0 98/08/13 */
3/*****************************************************************
4 * ceil
5 *
6 * Input:
7 *   x  - floating point value
8 *
9 * Output:
10 *   Smallest integer greater than x.
11 *
12 * Description:
13 *   This routine returns the smallest integer greater than x.
14 *
15 *****************************************************************/
16
17#include "fdlibm.h"
18#include "zmath.h"
19
20float
21ceilf (float x)
22{
23  float f, y;
24
25  y = modff (x, &f);
26
27  if (y == 0.0)
28    return (x);
29  else if (x > -1.0 && x < 1.0)
30    return (x > 0 ? 1.0 : 0.0);
31  else
32    return (x > 0 ? f + 1.0 : f);
33}
34
35#ifdef _DOUBLE_IS_32BITS
36double ceil (double x)
37{
38  return (double) ceilf ((float) x);
39}
40
41#endif /* defined(_DOUBLE_IS_32BITS) */
Note: See TracBrowser for help on using the repository browser.