PatchworkOS
Loading...
Searching...
No Matches
ceil.c
Go to the documentation of this file.
1
#include <math.h>
2
#include <
stdint.h
>
3
4
// https://en.cppreference.com/w/c/numeric/math/ceil
5
double
ceil
(
double
x
)
6
{
7
if
(
isinf
(
x
) ||
x
== 0.0 ||
x
== -0.0)
8
{
9
return
x
;
10
}
11
12
if
(
isnan
(
x
))
13
{
14
return
NAN
;
15
}
16
17
if
(
fabs
(
x
) >
INT64_MAX
)
18
{
19
return
x
;
20
}
21
22
int64_t
intPart = (
int64_t
)
x
;
23
if
(
x
> 0.0 && (
double
)intPart <
x
)
24
{
25
intPart++;
26
}
27
28
return
(
double
)intPart;
29
}
ceil
double ceil(double x)
Definition
ceil.c:5
isinf
#define isinf(x)
Definition
math.h:37
isnan
#define isnan(x)
Definition
math.h:39
NAN
#define NAN
Definition
math.h:20
fabs
double fabs(double x)
Definition
fabs.c:3
x
int64_t x
Definition
main.c:152
stdint.h
int64_t
__INT64_TYPE__ int64_t
Definition
stdint.h:16
INT64_MAX
#define INT64_MAX
Definition
stdint.h:73
src
libstd
user
functions
math
ceil.c
Generated by
1.9.8