all: Fix implicit conversion from double to float.
These are found when building with -Wfloat-conversion.
This commit is contained in:
parent
dc4d119d3d
commit
bcf01d1686
|
@ -362,7 +362,7 @@ STATIC mp_obj_t get_aligned(uint val_type, void *p, mp_int_t index) {
|
||||||
case FLOAT32:
|
case FLOAT32:
|
||||||
return mp_obj_new_float_from_f(((float *)p)[index]);
|
return mp_obj_new_float_from_f(((float *)p)[index]);
|
||||||
case FLOAT64:
|
case FLOAT64:
|
||||||
return mp_obj_new_float(((double *)p)[index]);
|
return mp_obj_new_float_from_d(((double *)p)[index]);
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
|
@ -23,15 +23,15 @@
|
||||||
|
|
||||||
// dpgeorge: pio2 was double in original implementation of asinf
|
// dpgeorge: pio2 was double in original implementation of asinf
|
||||||
static const float
|
static const float
|
||||||
pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
|
pio2_hi = 1.5707962513e+00f, /* 0x3fc90fda */
|
||||||
pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
|
pio2_lo = 7.5497894159e-08f; /* 0x33a22168 */
|
||||||
|
|
||||||
static const float
|
static const float
|
||||||
/* coefficients for R(x^2) */
|
/* coefficients for R(x^2) */
|
||||||
pS0 = 1.6666586697e-01,
|
pS0 = 1.6666586697e-01f,
|
||||||
pS1 = -4.2743422091e-02,
|
pS1 = -4.2743422091e-02f,
|
||||||
pS2 = -8.6563630030e-03,
|
pS2 = -8.6563630030e-03f,
|
||||||
qS1 = -7.0662963390e-01;
|
qS1 = -7.0662963390e-01f;
|
||||||
|
|
||||||
static float R(float z)
|
static float R(float z)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include "libm.h"
|
#include "libm.h"
|
||||||
|
|
||||||
static const float
|
static const float
|
||||||
pi = 3.1415927410e+00, /* 0x40490fdb */
|
pi = 3.1415927410e+00f, /* 0x40490fdb */
|
||||||
pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */
|
pi_lo = -8.7422776573e-08f; /* 0xb3bbbd2e */
|
||||||
|
|
||||||
float atan2f(float y, float x)
|
float atan2f(float y, float x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,25 +23,25 @@
|
||||||
#include "libm.h"
|
#include "libm.h"
|
||||||
|
|
||||||
static const float atanhi[] = {
|
static const float atanhi[] = {
|
||||||
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
|
4.6364760399e-01f, /* atan(0.5)hi 0x3eed6338 */
|
||||||
7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */
|
7.8539812565e-01f, /* atan(1.0)hi 0x3f490fda */
|
||||||
9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */
|
9.8279368877e-01f, /* atan(1.5)hi 0x3f7b985e */
|
||||||
1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */
|
1.5707962513e+00f, /* atan(inf)hi 0x3fc90fda */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float atanlo[] = {
|
static const float atanlo[] = {
|
||||||
5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */
|
5.0121582440e-09f, /* atan(0.5)lo 0x31ac3769 */
|
||||||
3.7748947079e-08, /* atan(1.0)lo 0x33222168 */
|
3.7748947079e-08f, /* atan(1.0)lo 0x33222168 */
|
||||||
3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */
|
3.4473217170e-08f, /* atan(1.5)lo 0x33140fb4 */
|
||||||
7.5497894159e-08, /* atan(inf)lo 0x33a22168 */
|
7.5497894159e-08f, /* atan(inf)lo 0x33a22168 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const float aT[] = {
|
static const float aT[] = {
|
||||||
3.3333328366e-01,
|
3.3333328366e-01f,
|
||||||
-1.9999158382e-01,
|
-1.9999158382e-01f,
|
||||||
1.4253635705e-01,
|
1.4253635705e-01f,
|
||||||
-1.0648017377e-01,
|
-1.0648017377e-01f,
|
||||||
6.1687607318e-02,
|
6.1687607318e-02f,
|
||||||
};
|
};
|
||||||
|
|
||||||
float atanf(float x)
|
float atanf(float x)
|
||||||
|
|
|
@ -93,16 +93,16 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
zero = 0.0000000000e+00, /* 0x00000000 */
|
zero = 0.0000000000e+00f, /* 0x00000000 */
|
||||||
half = 5.0000000000e-01, /* 0x3f000000 */
|
half = 5.0000000000e-01f, /* 0x3f000000 */
|
||||||
two8 = 2.5600000000e+02, /* 0x43800000 */
|
two8 = 2.5600000000e+02f, /* 0x43800000 */
|
||||||
invpio2 = 6.3661980629e-01, /* 0x3f22f984 */
|
invpio2 = 6.3661980629e-01f, /* 0x3f22f984 */
|
||||||
pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */
|
pio2_1 = 1.5707855225e+00f, /* 0x3fc90f80 */
|
||||||
pio2_1t = 1.0804334124e-05, /* 0x37354443 */
|
pio2_1t = 1.0804334124e-05f, /* 0x37354443 */
|
||||||
pio2_2 = 1.0804273188e-05, /* 0x37354400 */
|
pio2_2 = 1.0804273188e-05f, /* 0x37354400 */
|
||||||
pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */
|
pio2_2t = 6.0770999344e-11f, /* 0x2e85a308 */
|
||||||
pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */
|
pio2_3 = 6.0770943833e-11f, /* 0x2e85a300 */
|
||||||
pio2_3t = 6.1232342629e-17; /* 0x248d3132 */
|
pio2_3t = 6.1232342629e-17f; /* 0x248d3132 */
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
__int32_t __ieee754_rem_pio2f(float x, float *y)
|
__int32_t __ieee754_rem_pio2f(float x, float *y)
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
#include "fdlibm.h"
|
#include "fdlibm.h"
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
static const float one = 1.0, tiny=1.0e-30;
|
static const float one = 1.0f, tiny=1.0e-30f;
|
||||||
#else
|
#else
|
||||||
static float one = 1.0, tiny=1.0e-30;
|
static float one = 1.0f, tiny=1.0e-30f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// sqrtf is exactly __ieee754_sqrtf when _IEEE_LIBM defined
|
// sqrtf is exactly __ieee754_sqrtf when _IEEE_LIBM defined
|
||||||
|
|
|
@ -32,77 +32,77 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
two23= 8.3886080000e+06, /* 0x4b000000 */
|
two23= 8.3886080000e+06f, /* 0x4b000000 */
|
||||||
half= 5.0000000000e-01, /* 0x3f000000 */
|
half= 5.0000000000e-01f, /* 0x3f000000 */
|
||||||
one = 1.0000000000e+00, /* 0x3f800000 */
|
one = 1.0000000000e+00f, /* 0x3f800000 */
|
||||||
pi = 3.1415927410e+00, /* 0x40490fdb */
|
pi = 3.1415927410e+00f, /* 0x40490fdb */
|
||||||
a0 = 7.7215664089e-02, /* 0x3d9e233f */
|
a0 = 7.7215664089e-02f, /* 0x3d9e233f */
|
||||||
a1 = 3.2246702909e-01, /* 0x3ea51a66 */
|
a1 = 3.2246702909e-01f, /* 0x3ea51a66 */
|
||||||
a2 = 6.7352302372e-02, /* 0x3d89f001 */
|
a2 = 6.7352302372e-02f, /* 0x3d89f001 */
|
||||||
a3 = 2.0580807701e-02, /* 0x3ca89915 */
|
a3 = 2.0580807701e-02f, /* 0x3ca89915 */
|
||||||
a4 = 7.3855509982e-03, /* 0x3bf2027e */
|
a4 = 7.3855509982e-03f, /* 0x3bf2027e */
|
||||||
a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */
|
a5 = 2.8905137442e-03f, /* 0x3b3d6ec6 */
|
||||||
a6 = 1.1927076848e-03, /* 0x3a9c54a1 */
|
a6 = 1.1927076848e-03f, /* 0x3a9c54a1 */
|
||||||
a7 = 5.1006977446e-04, /* 0x3a05b634 */
|
a7 = 5.1006977446e-04f, /* 0x3a05b634 */
|
||||||
a8 = 2.2086278477e-04, /* 0x39679767 */
|
a8 = 2.2086278477e-04f, /* 0x39679767 */
|
||||||
a9 = 1.0801156895e-04, /* 0x38e28445 */
|
a9 = 1.0801156895e-04f, /* 0x38e28445 */
|
||||||
a10 = 2.5214456400e-05, /* 0x37d383a2 */
|
a10 = 2.5214456400e-05f, /* 0x37d383a2 */
|
||||||
a11 = 4.4864096708e-05, /* 0x383c2c75 */
|
a11 = 4.4864096708e-05f, /* 0x383c2c75 */
|
||||||
tc = 1.4616321325e+00, /* 0x3fbb16c3 */
|
tc = 1.4616321325e+00f, /* 0x3fbb16c3 */
|
||||||
tf = -1.2148628384e-01, /* 0xbdf8cdcd */
|
tf = -1.2148628384e-01f, /* 0xbdf8cdcd */
|
||||||
/* tt = -(tail of tf) */
|
/* tt = -(tail of tf) */
|
||||||
tt = 6.6971006518e-09, /* 0x31e61c52 */
|
tt = 6.6971006518e-09f, /* 0x31e61c52 */
|
||||||
t0 = 4.8383611441e-01, /* 0x3ef7b95e */
|
t0 = 4.8383611441e-01f, /* 0x3ef7b95e */
|
||||||
t1 = -1.4758771658e-01, /* 0xbe17213c */
|
t1 = -1.4758771658e-01f, /* 0xbe17213c */
|
||||||
t2 = 6.4624942839e-02, /* 0x3d845a15 */
|
t2 = 6.4624942839e-02f, /* 0x3d845a15 */
|
||||||
t3 = -3.2788541168e-02, /* 0xbd064d47 */
|
t3 = -3.2788541168e-02f, /* 0xbd064d47 */
|
||||||
t4 = 1.7970675603e-02, /* 0x3c93373d */
|
t4 = 1.7970675603e-02f, /* 0x3c93373d */
|
||||||
t5 = -1.0314224288e-02, /* 0xbc28fcfe */
|
t5 = -1.0314224288e-02f, /* 0xbc28fcfe */
|
||||||
t6 = 6.1005386524e-03, /* 0x3bc7e707 */
|
t6 = 6.1005386524e-03f, /* 0x3bc7e707 */
|
||||||
t7 = -3.6845202558e-03, /* 0xbb7177fe */
|
t7 = -3.6845202558e-03f, /* 0xbb7177fe */
|
||||||
t8 = 2.2596477065e-03, /* 0x3b141699 */
|
t8 = 2.2596477065e-03f, /* 0x3b141699 */
|
||||||
t9 = -1.4034647029e-03, /* 0xbab7f476 */
|
t9 = -1.4034647029e-03f, /* 0xbab7f476 */
|
||||||
t10 = 8.8108185446e-04, /* 0x3a66f867 */
|
t10 = 8.8108185446e-04f, /* 0x3a66f867 */
|
||||||
t11 = -5.3859531181e-04, /* 0xba0d3085 */
|
t11 = -5.3859531181e-04f, /* 0xba0d3085 */
|
||||||
t12 = 3.1563205994e-04, /* 0x39a57b6b */
|
t12 = 3.1563205994e-04f, /* 0x39a57b6b */
|
||||||
t13 = -3.1275415677e-04, /* 0xb9a3f927 */
|
t13 = -3.1275415677e-04f, /* 0xb9a3f927 */
|
||||||
t14 = 3.3552918467e-04, /* 0x39afe9f7 */
|
t14 = 3.3552918467e-04f, /* 0x39afe9f7 */
|
||||||
u0 = -7.7215664089e-02, /* 0xbd9e233f */
|
u0 = -7.7215664089e-02f, /* 0xbd9e233f */
|
||||||
u1 = 6.3282704353e-01, /* 0x3f2200f4 */
|
u1 = 6.3282704353e-01f, /* 0x3f2200f4 */
|
||||||
u2 = 1.4549225569e+00, /* 0x3fba3ae7 */
|
u2 = 1.4549225569e+00f, /* 0x3fba3ae7 */
|
||||||
u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */
|
u3 = 9.7771751881e-01f, /* 0x3f7a4bb2 */
|
||||||
u4 = 2.2896373272e-01, /* 0x3e6a7578 */
|
u4 = 2.2896373272e-01f, /* 0x3e6a7578 */
|
||||||
u5 = 1.3381091878e-02, /* 0x3c5b3c5e */
|
u5 = 1.3381091878e-02f, /* 0x3c5b3c5e */
|
||||||
v1 = 2.4559779167e+00, /* 0x401d2ebe */
|
v1 = 2.4559779167e+00f, /* 0x401d2ebe */
|
||||||
v2 = 2.1284897327e+00, /* 0x4008392d */
|
v2 = 2.1284897327e+00f, /* 0x4008392d */
|
||||||
v3 = 7.6928514242e-01, /* 0x3f44efdf */
|
v3 = 7.6928514242e-01f, /* 0x3f44efdf */
|
||||||
v4 = 1.0422264785e-01, /* 0x3dd572af */
|
v4 = 1.0422264785e-01f, /* 0x3dd572af */
|
||||||
v5 = 3.2170924824e-03, /* 0x3b52d5db */
|
v5 = 3.2170924824e-03f, /* 0x3b52d5db */
|
||||||
s0 = -7.7215664089e-02, /* 0xbd9e233f */
|
s0 = -7.7215664089e-02f, /* 0xbd9e233f */
|
||||||
s1 = 2.1498242021e-01, /* 0x3e5c245a */
|
s1 = 2.1498242021e-01f, /* 0x3e5c245a */
|
||||||
s2 = 3.2577878237e-01, /* 0x3ea6cc7a */
|
s2 = 3.2577878237e-01f, /* 0x3ea6cc7a */
|
||||||
s3 = 1.4635047317e-01, /* 0x3e15dce6 */
|
s3 = 1.4635047317e-01f, /* 0x3e15dce6 */
|
||||||
s4 = 2.6642270386e-02, /* 0x3cda40e4 */
|
s4 = 2.6642270386e-02f, /* 0x3cda40e4 */
|
||||||
s5 = 1.8402845599e-03, /* 0x3af135b4 */
|
s5 = 1.8402845599e-03f, /* 0x3af135b4 */
|
||||||
s6 = 3.1947532989e-05, /* 0x3805ff67 */
|
s6 = 3.1947532989e-05f, /* 0x3805ff67 */
|
||||||
r1 = 1.3920053244e+00, /* 0x3fb22d3b */
|
r1 = 1.3920053244e+00f, /* 0x3fb22d3b */
|
||||||
r2 = 7.2193557024e-01, /* 0x3f38d0c5 */
|
r2 = 7.2193557024e-01f, /* 0x3f38d0c5 */
|
||||||
r3 = 1.7193385959e-01, /* 0x3e300f6e */
|
r3 = 1.7193385959e-01f, /* 0x3e300f6e */
|
||||||
r4 = 1.8645919859e-02, /* 0x3c98bf54 */
|
r4 = 1.8645919859e-02f, /* 0x3c98bf54 */
|
||||||
r5 = 7.7794247773e-04, /* 0x3a4beed6 */
|
r5 = 7.7794247773e-04f, /* 0x3a4beed6 */
|
||||||
r6 = 7.3266842264e-06, /* 0x36f5d7bd */
|
r6 = 7.3266842264e-06f, /* 0x36f5d7bd */
|
||||||
w0 = 4.1893854737e-01, /* 0x3ed67f1d */
|
w0 = 4.1893854737e-01f, /* 0x3ed67f1d */
|
||||||
w1 = 8.3333335817e-02, /* 0x3daaaaab */
|
w1 = 8.3333335817e-02f, /* 0x3daaaaab */
|
||||||
w2 = -2.7777778450e-03, /* 0xbb360b61 */
|
w2 = -2.7777778450e-03f, /* 0xbb360b61 */
|
||||||
w3 = 7.9365057172e-04, /* 0x3a500cfd */
|
w3 = 7.9365057172e-04f, /* 0x3a500cfd */
|
||||||
w4 = -5.9518753551e-04, /* 0xba1c065c */
|
w4 = -5.9518753551e-04f, /* 0xba1c065c */
|
||||||
w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */
|
w5 = 8.3633989561e-04f, /* 0x3a5b3dd2 */
|
||||||
w6 = -1.6309292987e-03; /* 0xbad5c4e8 */
|
w6 = -1.6309292987e-03f; /* 0xbad5c4e8 */
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
static const float zero= 0.0000000000e+00;
|
static const float zero= 0.0000000000e+00f;
|
||||||
#else
|
#else
|
||||||
static float zero= 0.0000000000e+00;
|
static float zero= 0.0000000000e+00f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
|
|
|
@ -29,13 +29,13 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
one = 1.0000000000e+00, /* 0x3f800000 */
|
one = 1.0000000000e+00f, /* 0x3f800000 */
|
||||||
C1 = 4.1666667908e-02, /* 0x3d2aaaab */
|
C1 = 4.1666667908e-02f, /* 0x3d2aaaab */
|
||||||
C2 = -1.3888889225e-03, /* 0xbab60b61 */
|
C2 = -1.3888889225e-03f, /* 0xbab60b61 */
|
||||||
C3 = 2.4801587642e-05, /* 0x37d00d01 */
|
C3 = 2.4801587642e-05f, /* 0x37d00d01 */
|
||||||
C4 = -2.7557314297e-07, /* 0xb493f27c */
|
C4 = -2.7557314297e-07f, /* 0xb493f27c */
|
||||||
C5 = 2.0875723372e-09, /* 0x310f74f6 */
|
C5 = 2.0875723372e-09f, /* 0x310f74f6 */
|
||||||
C6 = -1.1359647598e-11; /* 0xad47d74e */
|
C6 = -1.1359647598e-11f; /* 0xad47d74e */
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
float __kernel_cosf(float x, float y)
|
float __kernel_cosf(float x, float y)
|
||||||
|
|
|
@ -38,17 +38,17 @@ static const float PIo2[] = {
|
||||||
#else
|
#else
|
||||||
static float PIo2[] = {
|
static float PIo2[] = {
|
||||||
#endif
|
#endif
|
||||||
1.5703125000e+00, /* 0x3fc90000 */
|
1.5703125000e+00f, /* 0x3fc90000 */
|
||||||
4.5776367188e-04, /* 0x39f00000 */
|
4.5776367188e-04f, /* 0x39f00000 */
|
||||||
2.5987625122e-05, /* 0x37da0000 */
|
2.5987625122e-05f, /* 0x37da0000 */
|
||||||
7.5437128544e-08, /* 0x33a20000 */
|
7.5437128544e-08f, /* 0x33a20000 */
|
||||||
6.0026650317e-11, /* 0x2e840000 */
|
6.0026650317e-11f, /* 0x2e840000 */
|
||||||
7.3896444519e-13, /* 0x2b500000 */
|
7.3896444519e-13f, /* 0x2b500000 */
|
||||||
5.3845816694e-15, /* 0x27c20000 */
|
5.3845816694e-15f, /* 0x27c20000 */
|
||||||
5.6378512969e-18, /* 0x22d00000 */
|
5.6378512969e-18f, /* 0x22d00000 */
|
||||||
8.3009228831e-20, /* 0x1fc40000 */
|
8.3009228831e-20f, /* 0x1fc40000 */
|
||||||
3.2756352257e-22, /* 0x1bc60000 */
|
3.2756352257e-22f, /* 0x1bc60000 */
|
||||||
6.3331015649e-25, /* 0x17440000 */
|
6.3331015649e-25f, /* 0x17440000 */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
|
@ -56,10 +56,10 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
zero = 0.0,
|
zero = 0.0f,
|
||||||
one = 1.0,
|
one = 1.0f,
|
||||||
two8 = 2.5600000000e+02, /* 0x43800000 */
|
two8 = 2.5600000000e+02f, /* 0x43800000 */
|
||||||
twon8 = 3.9062500000e-03; /* 0x3b800000 */
|
twon8 = 3.9062500000e-03f; /* 0x3b800000 */
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2)
|
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2)
|
||||||
|
|
|
@ -29,13 +29,13 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
half = 5.0000000000e-01,/* 0x3f000000 */
|
half = 5.0000000000e-01f,/* 0x3f000000 */
|
||||||
S1 = -1.6666667163e-01, /* 0xbe2aaaab */
|
S1 = -1.6666667163e-01f, /* 0xbe2aaaab */
|
||||||
S2 = 8.3333337680e-03, /* 0x3c088889 */
|
S2 = 8.3333337680e-03f, /* 0x3c088889 */
|
||||||
S3 = -1.9841270114e-04, /* 0xb9500d01 */
|
S3 = -1.9841270114e-04f, /* 0xb9500d01 */
|
||||||
S4 = 2.7557314297e-06, /* 0x3638ef1b */
|
S4 = 2.7557314297e-06f, /* 0x3638ef1b */
|
||||||
S5 = -2.5050759689e-08, /* 0xb2d72f34 */
|
S5 = -2.5050759689e-08f, /* 0xb2d72f34 */
|
||||||
S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */
|
S6 = 1.5896910177e-10f; /* 0x2f2ec9d3 */
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
float __kernel_sinf(float x, float y, int iy)
|
float __kernel_sinf(float x, float y, int iy)
|
||||||
|
|
|
@ -28,23 +28,23 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
one = 1.0000000000e+00, /* 0x3f800000 */
|
one = 1.0000000000e+00f, /* 0x3f800000 */
|
||||||
pio4 = 7.8539812565e-01, /* 0x3f490fda */
|
pio4 = 7.8539812565e-01f, /* 0x3f490fda */
|
||||||
pio4lo= 3.7748947079e-08, /* 0x33222168 */
|
pio4lo= 3.7748947079e-08f, /* 0x33222168 */
|
||||||
T[] = {
|
T[] = {
|
||||||
3.3333334327e-01, /* 0x3eaaaaab */
|
3.3333334327e-01f, /* 0x3eaaaaab */
|
||||||
1.3333334029e-01, /* 0x3e088889 */
|
1.3333334029e-01f, /* 0x3e088889 */
|
||||||
5.3968254477e-02, /* 0x3d5d0dd1 */
|
5.3968254477e-02f, /* 0x3d5d0dd1 */
|
||||||
2.1869488060e-02, /* 0x3cb327a4 */
|
2.1869488060e-02f, /* 0x3cb327a4 */
|
||||||
8.8632395491e-03, /* 0x3c11371f */
|
8.8632395491e-03f, /* 0x3c11371f */
|
||||||
3.5920790397e-03, /* 0x3b6b6916 */
|
3.5920790397e-03f, /* 0x3b6b6916 */
|
||||||
1.4562094584e-03, /* 0x3abede48 */
|
1.4562094584e-03f, /* 0x3abede48 */
|
||||||
5.8804126456e-04, /* 0x3a1a26c8 */
|
5.8804126456e-04f, /* 0x3a1a26c8 */
|
||||||
2.4646313977e-04, /* 0x398137b9 */
|
2.4646313977e-04f, /* 0x398137b9 */
|
||||||
7.8179444245e-05, /* 0x38a3f445 */
|
7.8179444245e-05f, /* 0x38a3f445 */
|
||||||
7.1407252108e-05, /* 0x3895c07a */
|
7.1407252108e-05f, /* 0x3895c07a */
|
||||||
-1.8558637748e-05, /* 0xb79bae5f */
|
-1.8558637748e-05f, /* 0xb79bae5f */
|
||||||
2.5907305826e-05, /* 0x37d95384 */
|
2.5907305826e-05f, /* 0x37d95384 */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
#include "libm.h"
|
#include "libm.h"
|
||||||
|
|
||||||
static const float
|
static const float
|
||||||
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
|
ln2_hi = 6.9313812256e-01f, /* 0x3f317180 */
|
||||||
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
|
ln2_lo = 9.0580006145e-06f, /* 0x3717f7d1 */
|
||||||
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
|
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
|
||||||
Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
|
Lg1 = 0xaaaaaa.0p-24f, /* 0.66666662693 */
|
||||||
Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
|
Lg2 = 0xccce13.0p-25f, /* 0.40000972152 */
|
||||||
Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
|
Lg3 = 0x91e9ee.0p-25f, /* 0.28498786688 */
|
||||||
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
|
Lg4 = 0xf89e26.0p-26f; /* 0.24279078841 */
|
||||||
|
|
||||||
float log1pf(float x)
|
float log1pf(float x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ float copysignf(float x, float y) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const float _M_LN10 = 2.30258509299404; // 0x40135d8e
|
static const float _M_LN10 = 2.30258509299404f; // 0x40135d8e
|
||||||
float log10f(float x) { return logf(x) / (float)_M_LN10; }
|
float log10f(float x) { return logf(x) / (float)_M_LN10; }
|
||||||
|
|
||||||
float tanhf(float x) {
|
float tanhf(float x) {
|
||||||
|
@ -139,34 +139,34 @@ float scalbnf(float x, int n)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const float
|
static const float
|
||||||
bp[] = {1.0, 1.5,},
|
bp[] = {1.0f, 1.5f,},
|
||||||
dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
|
dp_h[] = { 0.0f, 5.84960938e-01f,}, /* 0x3f15c000 */
|
||||||
dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
|
dp_l[] = { 0.0f, 1.56322085e-06f,}, /* 0x35d1cfdc */
|
||||||
two24 = 16777216.0, /* 0x4b800000 */
|
two24 = 16777216.0f, /* 0x4b800000 */
|
||||||
huge = 1.0e30,
|
huge = 1.0e30f,
|
||||||
tiny = 1.0e-30,
|
tiny = 1.0e-30f,
|
||||||
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
|
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
|
||||||
L1 = 6.0000002384e-01, /* 0x3f19999a */
|
L1 = 6.0000002384e-01f, /* 0x3f19999a */
|
||||||
L2 = 4.2857143283e-01, /* 0x3edb6db7 */
|
L2 = 4.2857143283e-01f, /* 0x3edb6db7 */
|
||||||
L3 = 3.3333334327e-01, /* 0x3eaaaaab */
|
L3 = 3.3333334327e-01f, /* 0x3eaaaaab */
|
||||||
L4 = 2.7272811532e-01, /* 0x3e8ba305 */
|
L4 = 2.7272811532e-01f, /* 0x3e8ba305 */
|
||||||
L5 = 2.3066075146e-01, /* 0x3e6c3255 */
|
L5 = 2.3066075146e-01f, /* 0x3e6c3255 */
|
||||||
L6 = 2.0697501302e-01, /* 0x3e53f142 */
|
L6 = 2.0697501302e-01f, /* 0x3e53f142 */
|
||||||
P1 = 1.6666667163e-01, /* 0x3e2aaaab */
|
P1 = 1.6666667163e-01f, /* 0x3e2aaaab */
|
||||||
P2 = -2.7777778450e-03, /* 0xbb360b61 */
|
P2 = -2.7777778450e-03f, /* 0xbb360b61 */
|
||||||
P3 = 6.6137559770e-05, /* 0x388ab355 */
|
P3 = 6.6137559770e-05f, /* 0x388ab355 */
|
||||||
P4 = -1.6533901999e-06, /* 0xb5ddea0e */
|
P4 = -1.6533901999e-06f, /* 0xb5ddea0e */
|
||||||
P5 = 4.1381369442e-08, /* 0x3331bb4c */
|
P5 = 4.1381369442e-08f, /* 0x3331bb4c */
|
||||||
lg2 = 6.9314718246e-01, /* 0x3f317218 */
|
lg2 = 6.9314718246e-01f, /* 0x3f317218 */
|
||||||
lg2_h = 6.93145752e-01, /* 0x3f317200 */
|
lg2_h = 6.93145752e-01f, /* 0x3f317200 */
|
||||||
lg2_l = 1.42860654e-06, /* 0x35bfbe8c */
|
lg2_l = 1.42860654e-06f, /* 0x35bfbe8c */
|
||||||
ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
|
ovt = 4.2995665694e-08f, /* -(128-log2(ovfl+.5ulp)) */
|
||||||
cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
|
cp = 9.6179670095e-01f, /* 0x3f76384f =2/(3ln2) */
|
||||||
cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */
|
cp_h = 9.6191406250e-01f, /* 0x3f764000 =12b cp */
|
||||||
cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */
|
cp_l = -1.1736857402e-04f, /* 0xb8f623c6 =tail of cp_h */
|
||||||
ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
|
ivln2 = 1.4426950216e+00f, /* 0x3fb8aa3b =1/ln2 */
|
||||||
ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
|
ivln2_h = 1.4426879883e+00f, /* 0x3fb8aa00 =16b 1/ln2*/
|
||||||
ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
|
ivln2_l = 7.0526075433e-06f; /* 0x36eca570 =1/ln2 tail*/
|
||||||
|
|
||||||
float powf(float x, float y)
|
float powf(float x, float y)
|
||||||
{
|
{
|
||||||
|
@ -403,7 +403,7 @@ float powf(float x, float y)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const float
|
static const float
|
||||||
half[2] = {0.5,-0.5},
|
half[2] = {0.5f,-0.5f},
|
||||||
ln2hi = 6.9314575195e-1f, /* 0x3f317200 */
|
ln2hi = 6.9314575195e-1f, /* 0x3f317200 */
|
||||||
ln2lo = 1.4286067653e-6f, /* 0x35bfbe8e */
|
ln2lo = 1.4286067653e-6f, /* 0x35bfbe8e */
|
||||||
invln2 = 1.4426950216e+0f, /* 0x3fb8aa3b */
|
invln2 = 1.4426950216e+0f, /* 0x3fb8aa3b */
|
||||||
|
@ -489,17 +489,17 @@ float expf(float x)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const float
|
static const float
|
||||||
o_threshold = 8.8721679688e+01, /* 0x42b17180 */
|
o_threshold = 8.8721679688e+01f, /* 0x42b17180 */
|
||||||
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
|
ln2_hi = 6.9313812256e-01f, /* 0x3f317180 */
|
||||||
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
|
ln2_lo = 9.0580006145e-06f, /* 0x3717f7d1 */
|
||||||
//invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
|
//invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
|
||||||
/*
|
/*
|
||||||
* Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]:
|
* Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]:
|
||||||
* |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04
|
* |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04
|
||||||
* Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c):
|
* Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c):
|
||||||
*/
|
*/
|
||||||
Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */
|
Q1 = -3.3333212137e-2f, /* -0x888868.0p-28 */
|
||||||
Q2 = 1.5807170421e-3; /* 0xcf3010.0p-33 */
|
Q2 = 1.5807170421e-3f; /* 0xcf3010.0p-33 */
|
||||||
|
|
||||||
float expm1f(float x)
|
float expm1f(float x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,79 +35,79 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
tiny = 1e-30,
|
tiny = 1e-30f,
|
||||||
half= 5.0000000000e-01, /* 0x3F000000 */
|
half= 5.0000000000e-01f, /* 0x3F000000 */
|
||||||
one = 1.0000000000e+00, /* 0x3F800000 */
|
one = 1.0000000000e+00f, /* 0x3F800000 */
|
||||||
two = 2.0000000000e+00, /* 0x40000000 */
|
two = 2.0000000000e+00f, /* 0x40000000 */
|
||||||
/* c = (subfloat)0.84506291151 */
|
/* c = (subfloat)0.84506291151 */
|
||||||
erx = 8.4506291151e-01, /* 0x3f58560b */
|
erx = 8.4506291151e-01f, /* 0x3f58560b */
|
||||||
/*
|
/*
|
||||||
* Coefficients for approximation to erf on [0,0.84375]
|
* Coefficients for approximation to erf on [0,0.84375]
|
||||||
*/
|
*/
|
||||||
efx = 1.2837916613e-01, /* 0x3e0375d4 */
|
efx = 1.2837916613e-01f, /* 0x3e0375d4 */
|
||||||
efx8= 1.0270333290e+00, /* 0x3f8375d4 */
|
efx8= 1.0270333290e+00f, /* 0x3f8375d4 */
|
||||||
pp0 = 1.2837916613e-01, /* 0x3e0375d4 */
|
pp0 = 1.2837916613e-01f, /* 0x3e0375d4 */
|
||||||
pp1 = -3.2504209876e-01, /* 0xbea66beb */
|
pp1 = -3.2504209876e-01f, /* 0xbea66beb */
|
||||||
pp2 = -2.8481749818e-02, /* 0xbce9528f */
|
pp2 = -2.8481749818e-02f, /* 0xbce9528f */
|
||||||
pp3 = -5.7702702470e-03, /* 0xbbbd1489 */
|
pp3 = -5.7702702470e-03f, /* 0xbbbd1489 */
|
||||||
pp4 = -2.3763017452e-05, /* 0xb7c756b1 */
|
pp4 = -2.3763017452e-05f, /* 0xb7c756b1 */
|
||||||
qq1 = 3.9791721106e-01, /* 0x3ecbbbce */
|
qq1 = 3.9791721106e-01f, /* 0x3ecbbbce */
|
||||||
qq2 = 6.5022252500e-02, /* 0x3d852a63 */
|
qq2 = 6.5022252500e-02f, /* 0x3d852a63 */
|
||||||
qq3 = 5.0813062117e-03, /* 0x3ba68116 */
|
qq3 = 5.0813062117e-03f, /* 0x3ba68116 */
|
||||||
qq4 = 1.3249473704e-04, /* 0x390aee49 */
|
qq4 = 1.3249473704e-04f, /* 0x390aee49 */
|
||||||
qq5 = -3.9602282413e-06, /* 0xb684e21a */
|
qq5 = -3.9602282413e-06f, /* 0xb684e21a */
|
||||||
/*
|
/*
|
||||||
* Coefficients for approximation to erf in [0.84375,1.25]
|
* Coefficients for approximation to erf in [0.84375,1.25]
|
||||||
*/
|
*/
|
||||||
pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */
|
pa0 = -2.3621185683e-03f, /* 0xbb1acdc6 */
|
||||||
pa1 = 4.1485610604e-01, /* 0x3ed46805 */
|
pa1 = 4.1485610604e-01f, /* 0x3ed46805 */
|
||||||
pa2 = -3.7220788002e-01, /* 0xbebe9208 */
|
pa2 = -3.7220788002e-01f, /* 0xbebe9208 */
|
||||||
pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */
|
pa3 = 3.1834661961e-01f, /* 0x3ea2fe54 */
|
||||||
pa4 = -1.1089469492e-01, /* 0xbde31cc2 */
|
pa4 = -1.1089469492e-01f, /* 0xbde31cc2 */
|
||||||
pa5 = 3.5478305072e-02, /* 0x3d1151b3 */
|
pa5 = 3.5478305072e-02f, /* 0x3d1151b3 */
|
||||||
pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */
|
pa6 = -2.1663755178e-03f, /* 0xbb0df9c0 */
|
||||||
qa1 = 1.0642088205e-01, /* 0x3dd9f331 */
|
qa1 = 1.0642088205e-01f, /* 0x3dd9f331 */
|
||||||
qa2 = 5.4039794207e-01, /* 0x3f0a5785 */
|
qa2 = 5.4039794207e-01f, /* 0x3f0a5785 */
|
||||||
qa3 = 7.1828655899e-02, /* 0x3d931ae7 */
|
qa3 = 7.1828655899e-02f, /* 0x3d931ae7 */
|
||||||
qa4 = 1.2617121637e-01, /* 0x3e013307 */
|
qa4 = 1.2617121637e-01f, /* 0x3e013307 */
|
||||||
qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */
|
qa5 = 1.3637083583e-02f, /* 0x3c5f6e13 */
|
||||||
qa6 = 1.1984500103e-02, /* 0x3c445aa3 */
|
qa6 = 1.1984500103e-02f, /* 0x3c445aa3 */
|
||||||
/*
|
/*
|
||||||
* Coefficients for approximation to erfc in [1.25,1/0.35]
|
* Coefficients for approximation to erfc in [1.25,1/0.35]
|
||||||
*/
|
*/
|
||||||
ra0 = -9.8649440333e-03, /* 0xbc21a093 */
|
ra0 = -9.8649440333e-03f, /* 0xbc21a093 */
|
||||||
ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */
|
ra1 = -6.9385856390e-01f, /* 0xbf31a0b7 */
|
||||||
ra2 = -1.0558626175e+01, /* 0xc128f022 */
|
ra2 = -1.0558626175e+01f, /* 0xc128f022 */
|
||||||
ra3 = -6.2375331879e+01, /* 0xc2798057 */
|
ra3 = -6.2375331879e+01f, /* 0xc2798057 */
|
||||||
ra4 = -1.6239666748e+02, /* 0xc322658c */
|
ra4 = -1.6239666748e+02f, /* 0xc322658c */
|
||||||
ra5 = -1.8460508728e+02, /* 0xc3389ae7 */
|
ra5 = -1.8460508728e+02f, /* 0xc3389ae7 */
|
||||||
ra6 = -8.1287437439e+01, /* 0xc2a2932b */
|
ra6 = -8.1287437439e+01f, /* 0xc2a2932b */
|
||||||
ra7 = -9.8143291473e+00, /* 0xc11d077e */
|
ra7 = -9.8143291473e+00f, /* 0xc11d077e */
|
||||||
sa1 = 1.9651271820e+01, /* 0x419d35ce */
|
sa1 = 1.9651271820e+01f, /* 0x419d35ce */
|
||||||
sa2 = 1.3765776062e+02, /* 0x4309a863 */
|
sa2 = 1.3765776062e+02f, /* 0x4309a863 */
|
||||||
sa3 = 4.3456588745e+02, /* 0x43d9486f */
|
sa3 = 4.3456588745e+02f, /* 0x43d9486f */
|
||||||
sa4 = 6.4538726807e+02, /* 0x442158c9 */
|
sa4 = 6.4538726807e+02f, /* 0x442158c9 */
|
||||||
sa5 = 4.2900814819e+02, /* 0x43d6810b */
|
sa5 = 4.2900814819e+02f, /* 0x43d6810b */
|
||||||
sa6 = 1.0863500214e+02, /* 0x42d9451f */
|
sa6 = 1.0863500214e+02f, /* 0x42d9451f */
|
||||||
sa7 = 6.5702495575e+00, /* 0x40d23f7c */
|
sa7 = 6.5702495575e+00f, /* 0x40d23f7c */
|
||||||
sa8 = -6.0424413532e-02, /* 0xbd777f97 */
|
sa8 = -6.0424413532e-02f, /* 0xbd777f97 */
|
||||||
/*
|
/*
|
||||||
* Coefficients for approximation to erfc in [1/.35,28]
|
* Coefficients for approximation to erfc in [1/.35,28]
|
||||||
*/
|
*/
|
||||||
rb0 = -9.8649431020e-03, /* 0xbc21a092 */
|
rb0 = -9.8649431020e-03f, /* 0xbc21a092 */
|
||||||
rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */
|
rb1 = -7.9928326607e-01f, /* 0xbf4c9dd4 */
|
||||||
rb2 = -1.7757955551e+01, /* 0xc18e104b */
|
rb2 = -1.7757955551e+01f, /* 0xc18e104b */
|
||||||
rb3 = -1.6063638306e+02, /* 0xc320a2ea */
|
rb3 = -1.6063638306e+02f, /* 0xc320a2ea */
|
||||||
rb4 = -6.3756646729e+02, /* 0xc41f6441 */
|
rb4 = -6.3756646729e+02f, /* 0xc41f6441 */
|
||||||
rb5 = -1.0250950928e+03, /* 0xc480230b */
|
rb5 = -1.0250950928e+03f, /* 0xc480230b */
|
||||||
rb6 = -4.8351919556e+02, /* 0xc3f1c275 */
|
rb6 = -4.8351919556e+02f, /* 0xc3f1c275 */
|
||||||
sb1 = 3.0338060379e+01, /* 0x41f2b459 */
|
sb1 = 3.0338060379e+01f, /* 0x41f2b459 */
|
||||||
sb2 = 3.2579251099e+02, /* 0x43a2e571 */
|
sb2 = 3.2579251099e+02f, /* 0x43a2e571 */
|
||||||
sb3 = 1.5367296143e+03, /* 0x44c01759 */
|
sb3 = 1.5367296143e+03f, /* 0x44c01759 */
|
||||||
sb4 = 3.1998581543e+03, /* 0x4547fdbb */
|
sb4 = 3.1998581543e+03f, /* 0x4547fdbb */
|
||||||
sb5 = 2.5530502930e+03, /* 0x451f90ce */
|
sb5 = 2.5530502930e+03f, /* 0x451f90ce */
|
||||||
sb6 = 4.7452853394e+02, /* 0x43ed43a7 */
|
sb6 = 4.7452853394e+02f, /* 0x43ed43a7 */
|
||||||
sb7 = -2.2440952301e+01; /* 0xc1b38712 */
|
sb7 = -2.2440952301e+01f; /* 0xc1b38712 */
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
float erff(float x)
|
float erff(float x)
|
||||||
|
|
|
@ -29,7 +29,7 @@ static const float
|
||||||
#else
|
#else
|
||||||
static float
|
static float
|
||||||
#endif
|
#endif
|
||||||
two25 = 3.3554432000e+07; /* 0x4c000000 */
|
two25 = 3.3554432000e+07f; /* 0x4c000000 */
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
float frexpf(float x, int *eptr)
|
float frexpf(float x, int *eptr)
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
#include "fdlibm.h"
|
#include "fdlibm.h"
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
static const float one = 1.0;
|
static const float one = 1.0f;
|
||||||
#else
|
#else
|
||||||
static float one = 1.0;
|
static float one = 1.0f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
|
|
|
@ -763,7 +763,7 @@ STATIC volatile float adc_refcor = 1.0f;
|
||||||
|
|
||||||
float adc_read_core_temp_float(ADC_HandleTypeDef *adcHandle) {
|
float adc_read_core_temp_float(ADC_HandleTypeDef *adcHandle) {
|
||||||
int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR);
|
int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR);
|
||||||
float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0;
|
float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0f;
|
||||||
return (((float)raw_value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f;
|
return (((float)raw_value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ STATIC uint32_t compute_prescaler_period_from_freq(pyb_timer_obj_t *self, mp_obj
|
||||||
if (0) {
|
if (0) {
|
||||||
#if MICROPY_PY_BUILTINS_FLOAT
|
#if MICROPY_PY_BUILTINS_FLOAT
|
||||||
} else if (mp_obj_is_type(freq_in, &mp_type_float)) {
|
} else if (mp_obj_is_type(freq_in, &mp_type_float)) {
|
||||||
float freq = mp_obj_get_float(freq_in);
|
float freq = mp_obj_get_float_to_f(freq_in);
|
||||||
if (freq <= 0) {
|
if (freq <= 0) {
|
||||||
goto bad_freq;
|
goto bad_freq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type) {
|
||||||
}
|
}
|
||||||
case 'd': {
|
case 'd': {
|
||||||
double *p = (double *)&val;
|
double *p = (double *)&val;
|
||||||
return mp_obj_new_float(*p);
|
return mp_obj_new_float_from_d(*p);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case 'O':
|
case 'O':
|
||||||
|
@ -378,7 +378,7 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
|
||||||
#if MICROPY_PY_BUILTINS_FLOAT
|
#if MICROPY_PY_BUILTINS_FLOAT
|
||||||
} else if (*argtype == 'f') {
|
} else if (*argtype == 'f') {
|
||||||
float *p = (float *)&values[i];
|
float *p = (float *)&values[i];
|
||||||
*p = mp_obj_get_float(a);
|
*p = mp_obj_get_float_to_f(a);
|
||||||
} else if (*argtype == 'd') {
|
} else if (*argtype == 'd') {
|
||||||
double *p = (double *)&values[i];
|
double *p = (double *)&values[i];
|
||||||
*p = mp_obj_get_float_to_d(a);
|
*p = mp_obj_get_float_to_d(a);
|
||||||
|
@ -415,7 +415,7 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
|
||||||
if (sizeof(ffi_arg) == 4 && self->rettype == 'd') {
|
if (sizeof(ffi_arg) == 4 && self->rettype == 'd') {
|
||||||
double retval;
|
double retval;
|
||||||
ffi_call(&self->cif, self->func, &retval, valueptrs);
|
ffi_call(&self->cif, self->func, &retval, valueptrs);
|
||||||
return mp_obj_new_float(retval);
|
return mp_obj_new_float_from_d(retval);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
|
@ -178,7 +178,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
|
||||||
case 'f':
|
case 'f':
|
||||||
return mp_obj_new_float_from_f(((float *)p)[index]);
|
return mp_obj_new_float_from_f(((float *)p)[index]);
|
||||||
case 'd':
|
case 'd':
|
||||||
return mp_obj_new_float(((double *)p)[index]);
|
return mp_obj_new_float_from_d(((double *)p)[index]);
|
||||||
#endif
|
#endif
|
||||||
// Extension to CPython: array of objects
|
// Extension to CPython: array of objects
|
||||||
case 'O':
|
case 'O':
|
||||||
|
@ -249,7 +249,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
|
||||||
union { uint64_t i;
|
union { uint64_t i;
|
||||||
double f;
|
double f;
|
||||||
} fpu = {val};
|
} fpu = {val};
|
||||||
return mp_obj_new_float(fpu.f);
|
return mp_obj_new_float_from_d(fpu.f);
|
||||||
#endif
|
#endif
|
||||||
} else if (is_signed(val_type)) {
|
} else if (is_signed(val_type)) {
|
||||||
if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {
|
if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {
|
||||||
|
@ -311,7 +311,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
|
||||||
union { uint32_t i;
|
union { uint32_t i;
|
||||||
float f;
|
float f;
|
||||||
} fp_sp;
|
} fp_sp;
|
||||||
fp_sp.f = mp_obj_get_float(val_in);
|
fp_sp.f = mp_obj_get_float_to_f(val_in);
|
||||||
val = fp_sp.i;
|
val = fp_sp.i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_obj_t val_
|
||||||
switch (typecode) {
|
switch (typecode) {
|
||||||
#if MICROPY_PY_BUILTINS_FLOAT
|
#if MICROPY_PY_BUILTINS_FLOAT
|
||||||
case 'f':
|
case 'f':
|
||||||
((float *)p)[index] = mp_obj_get_float(val_in);
|
((float *)p)[index] = mp_obj_get_float_to_f(val_in);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
((double *)p)[index] = mp_obj_get_float_to_d(val_in);
|
((double *)p)[index] = mp_obj_get_float_to_d(val_in);
|
||||||
|
|
|
@ -100,15 +100,15 @@ static inline int fp_isless1(float x) {
|
||||||
|
|
||||||
static const FPTYPE g_pos_pow[] = {
|
static const FPTYPE g_pos_pow[] = {
|
||||||
#if FPDECEXP > 32
|
#if FPDECEXP > 32
|
||||||
1e256, 1e128, 1e64,
|
MICROPY_FLOAT_CONST(1e256), MICROPY_FLOAT_CONST(1e128), MICROPY_FLOAT_CONST(1e64),
|
||||||
#endif
|
#endif
|
||||||
1e32, 1e16, 1e8, 1e4, 1e2, 1e1
|
MICROPY_FLOAT_CONST(1e32), MICROPY_FLOAT_CONST(1e16), MICROPY_FLOAT_CONST(1e8), MICROPY_FLOAT_CONST(1e4), MICROPY_FLOAT_CONST(1e2), MICROPY_FLOAT_CONST(1e1)
|
||||||
};
|
};
|
||||||
static const FPTYPE g_neg_pow[] = {
|
static const FPTYPE g_neg_pow[] = {
|
||||||
#if FPDECEXP > 32
|
#if FPDECEXP > 32
|
||||||
1e-256, 1e-128, 1e-64,
|
MICROPY_FLOAT_CONST(1e-256), MICROPY_FLOAT_CONST(1e-128), MICROPY_FLOAT_CONST(1e-64),
|
||||||
#endif
|
#endif
|
||||||
1e-32, 1e-16, 1e-8, 1e-4, 1e-2, 1e-1
|
MICROPY_FLOAT_CONST(1e-32), MICROPY_FLOAT_CONST(1e-16), MICROPY_FLOAT_CONST(1e-8), MICROPY_FLOAT_CONST(1e-4), MICROPY_FLOAT_CONST(1e-2), MICROPY_FLOAT_CONST(1e-1)
|
||||||
};
|
};
|
||||||
|
|
||||||
int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, char sign) {
|
int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, char sign) {
|
||||||
|
|
|
@ -542,7 +542,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'G': {
|
case 'G': {
|
||||||
#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE))
|
#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE))
|
||||||
mp_float_t f = va_arg(args, double);
|
mp_float_t f = (mp_float_t)va_arg(args, double);
|
||||||
chrs += mp_print_float(print, f, *fmt, flags, fill, width, prec);
|
chrs += mp_print_float(print, f, *fmt, flags, fill, width, prec);
|
||||||
#else
|
#else
|
||||||
#error Unknown MICROPY FLOAT IMPL
|
#error Unknown MICROPY FLOAT IMPL
|
||||||
|
|
|
@ -332,12 +332,13 @@ class RawCode(object):
|
||||||
"#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B"
|
"#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B"
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
"STATIC const mp_obj_float_t %s = {{&mp_type_float}, %.16g};" % (obj_name, obj)
|
"STATIC const mp_obj_float_t %s = {{&mp_type_float}, (mp_float_t)%.16g};"
|
||||||
|
% (obj_name, obj)
|
||||||
)
|
)
|
||||||
print("#endif")
|
print("#endif")
|
||||||
elif type(obj) is complex:
|
elif type(obj) is complex:
|
||||||
print(
|
print(
|
||||||
"STATIC const mp_obj_complex_t %s = {{&mp_type_complex}, %.16g, %.16g};"
|
"STATIC const mp_obj_complex_t %s = {{&mp_type_complex}, (mp_float_t)%.16g, (mp_float_t)%.16g};"
|
||||||
% (obj_name, obj.real, obj.imag)
|
% (obj_name, obj.real, obj.imag)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue