repo.or.cz
/
musl.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
fix the use of uninitialized value in regcomp
[musl.git]
/
src
/
math
/
coshf.c
blob
b09f2ee5751f4341cfb6cc759055279deda1d7cb
1
#include
"libm.h"
2
3
float
coshf
(
float
x
)
4
{
5
union
{
float
f
;
uint32_t
i
;}
u
= {.
f
=
x
};
6
uint32_t
w
;
7
float
t
;
8
9
/* |x| */
10
u
.
i
&=
0x7fffffff
;
11
x
=
u
.
f
;
12
w
=
u
.
i
;
13
14
/* |x| < log(2) */
15
if
(
w
<
0x3f317217
) {
16
if
(
w
<
0x3f800000
- (
12
<<
23
)) {
17
FORCE_EVAL
(
x
+
0x1
p
120
f
);
18
return
1
;
19
}
20
t
=
expm1f
(
x
);
21
return
1
+
t
*
t
/(
2
*(
1
+
t
));
22
}
23
24
/* |x| < log(FLT_MAX) */
25
if
(
w
<
0x42b17217
) {
26
t
=
expf
(
x
);
27
return
0.5
f
*(
t
+
1
/
t
);
28
}
29
30
/* |x| > log(FLT_MAX) or nan */
31
t
=
__expo2f
(
x
);
32
return
t
;
33
}