summaryrefslogtreecommitdiff
path: root/py/formatfloat.c
diff options
context:
space:
mode:
authorJeff Epler <jeff@adafruit.com>2021-03-15 13:50:49 -0500
committerGitHub <noreply@github.com>2021-03-15 13:50:49 -0500
commit05ed179e11599dd45a76dfb14ecf624d0ff96d68 (patch)
treea046c6d1f117814168150484ed1bf7840d3400d7 /py/formatfloat.c
parent3cbff45f9aac5ea2855bbc888083d356a91c80fe (diff)
parentf9b4189b4c640823dabb76de8effd2a836da2eb0 (diff)
Merge pull request #4362 from microDev1/code-formatting
Add code formatting and translations check
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);