Skip to content

Commit

Permalink
all: Fix implicit conversion from double to float.
Browse files Browse the repository at this point in the history
These are found when building with -Wfloat-conversion.
  • Loading branch information
stinos authored and dpgeorge committed Apr 18, 2020
1 parent dc4d119 commit bcf01d1
Show file tree
Hide file tree
Showing 23 changed files with 266 additions and 265 deletions.
2 changes: 1 addition & 1 deletion extmod/moductypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ STATIC mp_obj_t get_aligned(uint val_type, void *p, mp_int_t index) {
case FLOAT32:
return mp_obj_new_float_from_f(((float *)p)[index]);
case FLOAT64:
return mp_obj_new_float(((double *)p)[index]);
return mp_obj_new_float_from_d(((double *)p)[index]);
#endif
default:
assert(0);
Expand Down
12 changes: 6 additions & 6 deletions lib/libm/asinfacosf.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

// dpgeorge: pio2 was double in original implementation of asinf
static const float
pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
pio2_hi = 1.5707962513e+00f, /* 0x3fc90fda */
pio2_lo = 7.5497894159e-08f; /* 0x33a22168 */

static const float
/* coefficients for R(x^2) */
pS0 = 1.6666586697e-01,
pS1 = -4.2743422091e-02,
pS2 = -8.6563630030e-03,
qS1 = -7.0662963390e-01;
pS0 = 1.6666586697e-01f,
pS1 = -4.2743422091e-02f,
pS2 = -8.6563630030e-03f,
qS1 = -7.0662963390e-01f;

static float R(float z)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/libm/atan2f.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "libm.h"

static const float
pi = 3.1415927410e+00, /* 0x40490fdb */
pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */
pi = 3.1415927410e+00f, /* 0x40490fdb */
pi_lo = -8.7422776573e-08f; /* 0xb3bbbd2e */

float atan2f(float y, float x)
{
Expand Down
26 changes: 13 additions & 13 deletions lib/libm/atanf.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
#include "libm.h"

static const float atanhi[] = {
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */
4.6364760399e-01f, /* atan(0.5)hi 0x3eed6338 */
7.8539812565e-01f, /* atan(1.0)hi 0x3f490fda */
9.8279368877e-01f, /* atan(1.5)hi 0x3f7b985e */
1.5707962513e+00f, /* atan(inf)hi 0x3fc90fda */
};

static const float atanlo[] = {
5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */
3.7748947079e-08, /* atan(1.0)lo 0x33222168 */
3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */
7.5497894159e-08, /* atan(inf)lo 0x33a22168 */
5.0121582440e-09f, /* atan(0.5)lo 0x31ac3769 */
3.7748947079e-08f, /* atan(1.0)lo 0x33222168 */
3.4473217170e-08f, /* atan(1.5)lo 0x33140fb4 */
7.5497894159e-08f, /* atan(inf)lo 0x33a22168 */
};

static const float aT[] = {
3.3333328366e-01,
-1.9999158382e-01,
1.4253635705e-01,
-1.0648017377e-01,
6.1687607318e-02,
3.3333328366e-01f,
-1.9999158382e-01f,
1.4253635705e-01f,
-1.0648017377e-01f,
6.1687607318e-02f,
};

float atanf(float x)
Expand Down
20 changes: 10 additions & 10 deletions lib/libm/ef_rem_pio2.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ static const float
#else
static float
#endif
zero = 0.0000000000e+00, /* 0x00000000 */
half = 5.0000000000e-01, /* 0x3f000000 */
two8 = 2.5600000000e+02, /* 0x43800000 */
invpio2 = 6.3661980629e-01, /* 0x3f22f984 */
pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */
pio2_1t = 1.0804334124e-05, /* 0x37354443 */
pio2_2 = 1.0804273188e-05, /* 0x37354400 */
pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */
pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */
pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
zero = 0.0000000000e+00f, /* 0x00000000 */
half = 5.0000000000e-01f, /* 0x3f000000 */
two8 = 2.5600000000e+02f, /* 0x43800000 */
invpio2 = 6.3661980629e-01f, /* 0x3f22f984 */
pio2_1 = 1.5707855225e+00f, /* 0x3fc90f80 */
pio2_1t = 1.0804334124e-05f, /* 0x37354443 */
pio2_2 = 1.0804273188e-05f, /* 0x37354400 */
pio2_2t = 6.0770999344e-11f, /* 0x2e85a308 */
pio2_3 = 6.0770943833e-11f, /* 0x2e85a300 */
pio2_3t = 6.1232342629e-17f; /* 0x248d3132 */

#ifdef __STDC__
__int32_t __ieee754_rem_pio2f(float x, float *y)
Expand Down
4 changes: 2 additions & 2 deletions lib/libm/ef_sqrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include "fdlibm.h"

#ifdef __STDC__
static const float one = 1.0, tiny=1.0e-30;
static const float one = 1.0f, tiny=1.0e-30f;
#else
static float one = 1.0, tiny=1.0e-30;
static float one = 1.0f, tiny=1.0e-30f;
#endif

// sqrtf is exactly __ieee754_sqrtf when _IEEE_LIBM defined
Expand Down
134 changes: 67 additions & 67 deletions lib/libm/erf_lgamma.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,77 +32,77 @@ static const float
#else
static float
#endif
two23= 8.3886080000e+06, /* 0x4b000000 */
half= 5.0000000000e-01, /* 0x3f000000 */
one = 1.0000000000e+00, /* 0x3f800000 */
pi = 3.1415927410e+00, /* 0x40490fdb */
a0 = 7.7215664089e-02, /* 0x3d9e233f */
a1 = 3.2246702909e-01, /* 0x3ea51a66 */
a2 = 6.7352302372e-02, /* 0x3d89f001 */
a3 = 2.0580807701e-02, /* 0x3ca89915 */
a4 = 7.3855509982e-03, /* 0x3bf2027e */
a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */
a6 = 1.1927076848e-03, /* 0x3a9c54a1 */
a7 = 5.1006977446e-04, /* 0x3a05b634 */
a8 = 2.2086278477e-04, /* 0x39679767 */
a9 = 1.0801156895e-04, /* 0x38e28445 */
a10 = 2.5214456400e-05, /* 0x37d383a2 */
a11 = 4.4864096708e-05, /* 0x383c2c75 */
tc = 1.4616321325e+00, /* 0x3fbb16c3 */
tf = -1.2148628384e-01, /* 0xbdf8cdcd */
two23= 8.3886080000e+06f, /* 0x4b000000 */
half= 5.0000000000e-01f, /* 0x3f000000 */
one = 1.0000000000e+00f, /* 0x3f800000 */
pi = 3.1415927410e+00f, /* 0x40490fdb */
a0 = 7.7215664089e-02f, /* 0x3d9e233f */
a1 = 3.2246702909e-01f, /* 0x3ea51a66 */
a2 = 6.7352302372e-02f, /* 0x3d89f001 */
a3 = 2.0580807701e-02f, /* 0x3ca89915 */
a4 = 7.3855509982e-03f, /* 0x3bf2027e */
a5 = 2.8905137442e-03f, /* 0x3b3d6ec6 */
a6 = 1.1927076848e-03f, /* 0x3a9c54a1 */
a7 = 5.1006977446e-04f, /* 0x3a05b634 */
a8 = 2.2086278477e-04f, /* 0x39679767 */
a9 = 1.0801156895e-04f, /* 0x38e28445 */
a10 = 2.5214456400e-05f, /* 0x37d383a2 */
a11 = 4.4864096708e-05f, /* 0x383c2c75 */
tc = 1.4616321325e+00f, /* 0x3fbb16c3 */
tf = -1.2148628384e-01f, /* 0xbdf8cdcd */
/* tt = -(tail of tf) */
tt = 6.6971006518e-09, /* 0x31e61c52 */
t0 = 4.8383611441e-01, /* 0x3ef7b95e */
t1 = -1.4758771658e-01, /* 0xbe17213c */
t2 = 6.4624942839e-02, /* 0x3d845a15 */
t3 = -3.2788541168e-02, /* 0xbd064d47 */
t4 = 1.7970675603e-02, /* 0x3c93373d */
t5 = -1.0314224288e-02, /* 0xbc28fcfe */
t6 = 6.1005386524e-03, /* 0x3bc7e707 */
t7 = -3.6845202558e-03, /* 0xbb7177fe */
t8 = 2.2596477065e-03, /* 0x3b141699 */
t9 = -1.4034647029e-03, /* 0xbab7f476 */
t10 = 8.8108185446e-04, /* 0x3a66f867 */
t11 = -5.3859531181e-04, /* 0xba0d3085 */
t12 = 3.1563205994e-04, /* 0x39a57b6b */
t13 = -3.1275415677e-04, /* 0xb9a3f927 */
t14 = 3.3552918467e-04, /* 0x39afe9f7 */
u0 = -7.7215664089e-02, /* 0xbd9e233f */
u1 = 6.3282704353e-01, /* 0x3f2200f4 */
u2 = 1.4549225569e+00, /* 0x3fba3ae7 */
u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */
u4 = 2.2896373272e-01, /* 0x3e6a7578 */
u5 = 1.3381091878e-02, /* 0x3c5b3c5e */
v1 = 2.4559779167e+00, /* 0x401d2ebe */
v2 = 2.1284897327e+00, /* 0x4008392d */
v3 = 7.6928514242e-01, /* 0x3f44efdf */
v4 = 1.0422264785e-01, /* 0x3dd572af */
v5 = 3.2170924824e-03, /* 0x3b52d5db */
s0 = -7.7215664089e-02, /* 0xbd9e233f */
s1 = 2.1498242021e-01, /* 0x3e5c245a */
s2 = 3.2577878237e-01, /* 0x3ea6cc7a */
s3 = 1.4635047317e-01, /* 0x3e15dce6 */
s4 = 2.6642270386e-02, /* 0x3cda40e4 */
s5 = 1.8402845599e-03, /* 0x3af135b4 */
s6 = 3.1947532989e-05, /* 0x3805ff67 */
r1 = 1.3920053244e+00, /* 0x3fb22d3b */
r2 = 7.2193557024e-01, /* 0x3f38d0c5 */
r3 = 1.7193385959e-01, /* 0x3e300f6e */
r4 = 1.8645919859e-02, /* 0x3c98bf54 */
r5 = 7.7794247773e-04, /* 0x3a4beed6 */
r6 = 7.3266842264e-06, /* 0x36f5d7bd */
w0 = 4.1893854737e-01, /* 0x3ed67f1d */
w1 = 8.3333335817e-02, /* 0x3daaaaab */
w2 = -2.7777778450e-03, /* 0xbb360b61 */
w3 = 7.9365057172e-04, /* 0x3a500cfd */
w4 = -5.9518753551e-04, /* 0xba1c065c */
w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */
w6 = -1.6309292987e-03; /* 0xbad5c4e8 */
tt = 6.6971006518e-09f, /* 0x31e61c52 */
t0 = 4.8383611441e-01f, /* 0x3ef7b95e */
t1 = -1.4758771658e-01f, /* 0xbe17213c */
t2 = 6.4624942839e-02f, /* 0x3d845a15 */
t3 = -3.2788541168e-02f, /* 0xbd064d47 */
t4 = 1.7970675603e-02f, /* 0x3c93373d */
t5 = -1.0314224288e-02f, /* 0xbc28fcfe */
t6 = 6.1005386524e-03f, /* 0x3bc7e707 */
t7 = -3.6845202558e-03f, /* 0xbb7177fe */
t8 = 2.2596477065e-03f, /* 0x3b141699 */
t9 = -1.4034647029e-03f, /* 0xbab7f476 */
t10 = 8.8108185446e-04f, /* 0x3a66f867 */
t11 = -5.3859531181e-04f, /* 0xba0d3085 */
t12 = 3.1563205994e-04f, /* 0x39a57b6b */
t13 = -3.1275415677e-04f, /* 0xb9a3f927 */
t14 = 3.3552918467e-04f, /* 0x39afe9f7 */
u0 = -7.7215664089e-02f, /* 0xbd9e233f */
u1 = 6.3282704353e-01f, /* 0x3f2200f4 */
u2 = 1.4549225569e+00f, /* 0x3fba3ae7 */
u3 = 9.7771751881e-01f, /* 0x3f7a4bb2 */
u4 = 2.2896373272e-01f, /* 0x3e6a7578 */
u5 = 1.3381091878e-02f, /* 0x3c5b3c5e */
v1 = 2.4559779167e+00f, /* 0x401d2ebe */
v2 = 2.1284897327e+00f, /* 0x4008392d */
v3 = 7.6928514242e-01f, /* 0x3f44efdf */
v4 = 1.0422264785e-01f, /* 0x3dd572af */
v5 = 3.2170924824e-03f, /* 0x3b52d5db */
s0 = -7.7215664089e-02f, /* 0xbd9e233f */
s1 = 2.1498242021e-01f, /* 0x3e5c245a */
s2 = 3.2577878237e-01f, /* 0x3ea6cc7a */
s3 = 1.4635047317e-01f, /* 0x3e15dce6 */
s4 = 2.6642270386e-02f, /* 0x3cda40e4 */
s5 = 1.8402845599e-03f, /* 0x3af135b4 */
s6 = 3.1947532989e-05f, /* 0x3805ff67 */
r1 = 1.3920053244e+00f, /* 0x3fb22d3b */
r2 = 7.2193557024e-01f, /* 0x3f38d0c5 */
r3 = 1.7193385959e-01f, /* 0x3e300f6e */
r4 = 1.8645919859e-02f, /* 0x3c98bf54 */
r5 = 7.7794247773e-04f, /* 0x3a4beed6 */
r6 = 7.3266842264e-06f, /* 0x36f5d7bd */
w0 = 4.1893854737e-01f, /* 0x3ed67f1d */
w1 = 8.3333335817e-02f, /* 0x3daaaaab */
w2 = -2.7777778450e-03f, /* 0xbb360b61 */
w3 = 7.9365057172e-04f, /* 0x3a500cfd */
w4 = -5.9518753551e-04f, /* 0xba1c065c */
w5 = 8.3633989561e-04f, /* 0x3a5b3dd2 */
w6 = -1.6309292987e-03f; /* 0xbad5c4e8 */

#ifdef __STDC__
static const float zero= 0.0000000000e+00;
static const float zero= 0.0000000000e+00f;
#else
static float zero= 0.0000000000e+00;
static float zero= 0.0000000000e+00f;
#endif

#ifdef __STDC__
Expand Down
14 changes: 7 additions & 7 deletions lib/libm/kf_cos.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ static const float
#else
static float
#endif
one = 1.0000000000e+00, /* 0x3f800000 */
C1 = 4.1666667908e-02, /* 0x3d2aaaab */
C2 = -1.3888889225e-03, /* 0xbab60b61 */
C3 = 2.4801587642e-05, /* 0x37d00d01 */
C4 = -2.7557314297e-07, /* 0xb493f27c */
C5 = 2.0875723372e-09, /* 0x310f74f6 */
C6 = -1.1359647598e-11; /* 0xad47d74e */
one = 1.0000000000e+00f, /* 0x3f800000 */
C1 = 4.1666667908e-02f, /* 0x3d2aaaab */
C2 = -1.3888889225e-03f, /* 0xbab60b61 */
C3 = 2.4801587642e-05f, /* 0x37d00d01 */
C4 = -2.7557314297e-07f, /* 0xb493f27c */
C5 = 2.0875723372e-09f, /* 0x310f74f6 */
C6 = -1.1359647598e-11f; /* 0xad47d74e */

#ifdef __STDC__
float __kernel_cosf(float x, float y)
Expand Down
30 changes: 15 additions & 15 deletions lib/libm/kf_rem_pio2.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ static const float PIo2[] = {
#else
static float PIo2[] = {
#endif
1.5703125000e+00, /* 0x3fc90000 */
4.5776367188e-04, /* 0x39f00000 */
2.5987625122e-05, /* 0x37da0000 */
7.5437128544e-08, /* 0x33a20000 */
6.0026650317e-11, /* 0x2e840000 */
7.3896444519e-13, /* 0x2b500000 */
5.3845816694e-15, /* 0x27c20000 */
5.6378512969e-18, /* 0x22d00000 */
8.3009228831e-20, /* 0x1fc40000 */
3.2756352257e-22, /* 0x1bc60000 */
6.3331015649e-25, /* 0x17440000 */
1.5703125000e+00f, /* 0x3fc90000 */
4.5776367188e-04f, /* 0x39f00000 */
2.5987625122e-05f, /* 0x37da0000 */
7.5437128544e-08f, /* 0x33a20000 */
6.0026650317e-11f, /* 0x2e840000 */
7.3896444519e-13f, /* 0x2b500000 */
5.3845816694e-15f, /* 0x27c20000 */
5.6378512969e-18f, /* 0x22d00000 */
8.3009228831e-20f, /* 0x1fc40000 */
3.2756352257e-22f, /* 0x1bc60000 */
6.3331015649e-25f, /* 0x17440000 */
};

#ifdef __STDC__
static const float
#else
static float
#endif
zero = 0.0,
one = 1.0,
two8 = 2.5600000000e+02, /* 0x43800000 */
twon8 = 3.9062500000e-03; /* 0x3b800000 */
zero = 0.0f,
one = 1.0f,
two8 = 2.5600000000e+02f, /* 0x43800000 */
twon8 = 3.9062500000e-03f; /* 0x3b800000 */

#ifdef __STDC__
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2)
Expand Down
14 changes: 7 additions & 7 deletions lib/libm/kf_sin.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ static const float
#else
static float
#endif
half = 5.0000000000e-01,/* 0x3f000000 */
S1 = -1.6666667163e-01, /* 0xbe2aaaab */
S2 = 8.3333337680e-03, /* 0x3c088889 */
S3 = -1.9841270114e-04, /* 0xb9500d01 */
S4 = 2.7557314297e-06, /* 0x3638ef1b */
S5 = -2.5050759689e-08, /* 0xb2d72f34 */
S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */
half = 5.0000000000e-01f,/* 0x3f000000 */
S1 = -1.6666667163e-01f, /* 0xbe2aaaab */
S2 = 8.3333337680e-03f, /* 0x3c088889 */
S3 = -1.9841270114e-04f, /* 0xb9500d01 */
S4 = 2.7557314297e-06f, /* 0x3638ef1b */
S5 = -2.5050759689e-08f, /* 0xb2d72f34 */
S6 = 1.5896910177e-10f; /* 0x2f2ec9d3 */

#ifdef __STDC__
float __kernel_sinf(float x, float y, int iy)
Expand Down
32 changes: 16 additions & 16 deletions lib/libm/kf_tan.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ static const float
#else
static float
#endif
one = 1.0000000000e+00, /* 0x3f800000 */
pio4 = 7.8539812565e-01, /* 0x3f490fda */
pio4lo= 3.7748947079e-08, /* 0x33222168 */
one = 1.0000000000e+00f, /* 0x3f800000 */
pio4 = 7.8539812565e-01f, /* 0x3f490fda */
pio4lo= 3.7748947079e-08f, /* 0x33222168 */
T[] = {
3.3333334327e-01, /* 0x3eaaaaab */
1.3333334029e-01, /* 0x3e088889 */
5.3968254477e-02, /* 0x3d5d0dd1 */
2.1869488060e-02, /* 0x3cb327a4 */
8.8632395491e-03, /* 0x3c11371f */
3.5920790397e-03, /* 0x3b6b6916 */
1.4562094584e-03, /* 0x3abede48 */
5.8804126456e-04, /* 0x3a1a26c8 */
2.4646313977e-04, /* 0x398137b9 */
7.8179444245e-05, /* 0x38a3f445 */
7.1407252108e-05, /* 0x3895c07a */
-1.8558637748e-05, /* 0xb79bae5f */
2.5907305826e-05, /* 0x37d95384 */
3.3333334327e-01f, /* 0x3eaaaaab */
1.3333334029e-01f, /* 0x3e088889 */
5.3968254477e-02f, /* 0x3d5d0dd1 */
2.1869488060e-02f, /* 0x3cb327a4 */
8.8632395491e-03f, /* 0x3c11371f */
3.5920790397e-03f, /* 0x3b6b6916 */
1.4562094584e-03f, /* 0x3abede48 */
5.8804126456e-04f, /* 0x3a1a26c8 */
2.4646313977e-04f, /* 0x398137b9 */
7.8179444245e-05f, /* 0x38a3f445 */
7.1407252108e-05f, /* 0x3895c07a */
-1.8558637748e-05f, /* 0xb79bae5f */
2.5907305826e-05f, /* 0x37d95384 */
};

#ifdef __STDC__
Expand Down
Loading

0 comments on commit bcf01d1

Please sign in to comment.