fix regression in access to optopt object
[musl.git] / src / math / exp10f.c
blobd009f0a84fdd9f15010ee83de729b86e50f69caf
1 #define _GNU_SOURCE
2 #include <math.h>
3 #include <stdint.h>
5 float exp10f(float x)
7 static const float p10[] = {
8 1e-7f, 1e-6f, 1e-5f, 1e-4f, 1e-3f, 1e-2f, 1e-1f,
9 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7
11 float n, y = modff(x, &n);
12 union {float f; uint32_t i;} u = {n};
13 /* fabsf(n) < 8 without raising invalid on nan */
14 if ((u.i>>23 & 0xff) < 0x7f+3) {
15 if (!y) return p10[(int)n+7];
16 y = exp2f(3.32192809488736234787031942948939f * y);
17 return y * p10[(int)n+7];
19 return exp2(3.32192809488736234787031942948939 * x);
22 weak_alias(exp10f, pow10f);