summaryrefslogtreecommitdiff
path: root/py/formatfloat.c
diff options
context:
space:
mode:
authorMark <56205165+gamblor21@users.noreply.github.com>2021-03-15 20:00:13 -0500
committerGitHub <noreply@github.com>2021-03-15 20:00:13 -0500
commite326d7ca800ce7101ddce001320c5349ee5ddeb6 (patch)
tree000a06790af7a8d27e9ba9fc27e10015815e1509 /py/formatfloat.c
parent307d2a99febbf6cdff824131dddc2ef938f5ea13 (diff)
parentf7a988b9b307141611b07f6dc9da5b26e982c154 (diff)
Merge branch 'main' into rp_dp_parallel
Diffstat (limited to 'py/formatfloat.c')
-rw-r--r--py/formatfloat.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/py/formatfloat.c b/py/formatfloat.c
index 166a98a2e..f8d06d2d7 100644
--- a/py/formatfloat.c
+++ b/py/formatfloat.c
@@ -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
@@ -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);