Skip to content

Commit

Permalink
lib/libm: Fix tanhf so that it correctly handles +/- infinity args.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgeorge committed Oct 4, 2017
1 parent 23faf88 commit f869d6b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/libm/math.c
Expand Up @@ -61,7 +61,12 @@ float log2f(float x) { return logf(x) / (float)_M_LN2; }
static const float _M_LN10 = 2.30258509299404; // 0x40135d8e
float log10f(float x) { return logf(x) / (float)_M_LN10; }

float tanhf(float x) { return sinhf(x) / coshf(x); }
float tanhf(float x) {
if (isinf(x)) {
return copysignf(1, x);
}
return sinhf(x) / coshf(x);
}

/*****************************************************************************/
/*****************************************************************************/
Expand Down

0 comments on commit f869d6b

Please sign in to comment.