mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-20 01:08:15 +01:00
Update MicroPython from 1.12 to 1.17
This commit is contained in:
@@ -68,11 +68,20 @@ union floatbits {
|
||||
float f;
|
||||
uint32_t u;
|
||||
};
|
||||
static inline int fp_signbit(float x) { union floatbits fb = {x}; return fb.u & FLT_SIGN_MASK; }
|
||||
static inline int fp_signbit(float x) {
|
||||
union floatbits fb = {x};
|
||||
return fb.u & FLT_SIGN_MASK;
|
||||
}
|
||||
#define fp_isnan(x) isnan(x)
|
||||
#define fp_isinf(x) isinf(x)
|
||||
static inline int fp_iszero(float x) { union floatbits fb = {x}; return fb.u == 0; }
|
||||
static inline int fp_isless1(float x) { union floatbits fb = {x}; return fb.u < 0x3f800000; }
|
||||
static inline int fp_iszero(float x) {
|
||||
union floatbits fb = {x};
|
||||
return fb.u == 0;
|
||||
}
|
||||
static inline int fp_isless1(float x) {
|
||||
union floatbits fb = {x};
|
||||
return fb.u < 0x3f800000;
|
||||
}
|
||||
|
||||
#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
|
||||
|
||||
@@ -91,15 +100,15 @@ static inline int fp_isless1(float x) { union floatbits fb = {x}; return fb.u <
|
||||
|
||||
static const FPTYPE g_pos_pow[] = {
|
||||
#if FPDECEXP > 32
|
||||
1e256, 1e128, 1e64,
|
||||
MICROPY_FLOAT_CONST(1e256), MICROPY_FLOAT_CONST(1e128), MICROPY_FLOAT_CONST(1e64),
|
||||
#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[] = {
|
||||
#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
|
||||
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) {
|
||||
@@ -282,7 +291,7 @@ int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, ch
|
||||
if (fmt == 'e' && prec > (buf_remaining - FPMIN_BUF_SIZE)) {
|
||||
prec = buf_remaining - FPMIN_BUF_SIZE;
|
||||
}
|
||||
if (fmt == 'g'){
|
||||
if (fmt == 'g') {
|
||||
// Truncate precision to prevent buffer overflow
|
||||
if (prec + (FPMIN_BUF_SIZE - 1) > buf_remaining) {
|
||||
prec = buf_remaining - (FPMIN_BUF_SIZE - 1);
|
||||
|
||||
Reference in New Issue
Block a user