From 879cb550a61051529324e000b50bd8c2c296ba0a Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 18 Apr 2019 17:24:59 +0000 Subject: [PATCH] Whitespace git-svn-id: https://svn.eduke32.com/eduke32@7598 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/fix16_str.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/source/build/src/fix16_str.cpp b/source/build/src/fix16_str.cpp index 59cdfdb84..d295cd541 100644 --- a/source/build/src/fix16_str.cpp +++ b/source/build/src/fix16_str.cpp @@ -12,14 +12,14 @@ static char *itoa_loop(char *buf, uint32_t scale, uint32_t value, bool skip) while (scale) { unsigned digit = (value / scale); - + if (!skip || digit || scale == 1) { skip = false; *buf++ = '0' + digit; value %= scale; } - + scale /= 10; } return buf; @@ -36,24 +36,24 @@ void fix16_to_str(fix16_t value, char *buf, int decimals) uint32_t fracpart = uvalue & 0xFFFF; uint32_t scale = scales[decimals & 7]; fracpart = fix16_mul(fracpart, scale); - + if (fracpart >= scale) { /* Handle carry from decimal part */ intpart++; - fracpart -= scale; + fracpart -= scale; } - + /* Format integer part */ buf = itoa_loop(buf, 10000, intpart, true); - + /* Format decimal part (if any) */ if (scale != 1) { *buf++ = '.'; buf = itoa_loop(buf, scale / 10, fracpart, false); } - + *buf = '\0'; } @@ -61,7 +61,7 @@ fix16_t fix16_from_str(const char *buf) { while (isspace(*buf)) buf++; - + /* Decode the sign */ bool negative = (*buf == '-'); if (*buf == '+' || *buf == '-') @@ -76,18 +76,18 @@ fix16_t fix16_from_str(const char *buf) intpart += *buf++ - '0'; count++; } - + if (count == 0 || count > 5 || intpart > 32768 || (!negative && intpart > 32767)) return FIX16_OVERFLOW; - + fix16_t value = intpart << 16; - + /* Decode the decimal part */ if (*buf == '.' || *buf == ',') { buf++; - + uint32_t fracpart = 0; uint32_t scale = 1; while (isdigit(*buf) && scale < 100000) @@ -96,19 +96,19 @@ fix16_t fix16_from_str(const char *buf) fracpart *= 10; fracpart += *buf++ - '0'; } - + value += fix16_div(fracpart, scale); } - + /* Verify that there is no garbage left over */ while (*buf != '\0') { if (!isdigit(*buf) && !isspace(*buf)) return FIX16_OVERFLOW; - + buf++; } - + return negative ? -value : value; }