Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: fusl/src/math/coshf.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "libm.h" 1 #include "libm.h"
2 2
3 float coshf(float x) 3 float coshf(float x) {
4 { 4 union {
5 » union {float f; uint32_t i;} u = {.f = x}; 5 float f;
6 » uint32_t w; 6 uint32_t i;
7 » float t; 7 } u = {.f = x};
8 uint32_t w;
9 float t;
8 10
9 » /* |x| */ 11 /* |x| */
10 » u.i &= 0x7fffffff; 12 u.i &= 0x7fffffff;
11 » x = u.f; 13 x = u.f;
12 » w = u.i; 14 w = u.i;
13 15
14 » /* |x| < log(2) */ 16 /* |x| < log(2) */
15 » if (w < 0x3f317217) { 17 if (w < 0x3f317217) {
16 » » if (w < 0x3f800000 - (12<<23)) { 18 if (w < 0x3f800000 - (12 << 23)) {
17 » » » FORCE_EVAL(x + 0x1p120f); 19 FORCE_EVAL(x + 0x1p120f);
18 » » » return 1; 20 return 1;
19 » » } 21 }
20 » » t = expm1f(x); 22 t = expm1f(x);
21 » » return 1 + t*t/(2*(1+t)); 23 return 1 + t * t / (2 * (1 + t));
22 » } 24 }
23 25
24 » /* |x| < log(FLT_MAX) */ 26 /* |x| < log(FLT_MAX) */
25 » if (w < 0x42b17217) { 27 if (w < 0x42b17217) {
26 » » t = expf(x); 28 t = expf(x);
27 » » return 0.5f*(t + 1/t); 29 return 0.5f * (t + 1 / t);
28 » } 30 }
29 31
30 » /* |x| > log(FLT_MAX) or nan */ 32 /* |x| > log(FLT_MAX) or nan */
31 » t = __expo2f(x); 33 t = __expo2f(x);
32 » return t; 34 return t;
33 } 35 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698