Merge branch 'master' into master

This commit is contained in:
DiSlord 2020-02-25 06:35:06 +03:00 committed by GitHub
commit a4e9b7a139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,9 @@
// ' ' Prepends a space for positive signed-numeric types. positive = ' ', negative = '-'. This flag is ignored if the + flag exists. // ' ' Prepends a space for positive signed-numeric types. positive = ' ', negative = '-'. This flag is ignored if the + flag exists.
//#define CHPRINTF_USE_SPACE_FLAG //#define CHPRINTF_USE_SPACE_FLAG
// Force putting trailing zeros on float value
#define CHPRINTF_FORCE_TRAILING_ZEROS
#define MAX_FILLER 11 #define MAX_FILLER 11
#define FLOAT_PRECISION 9 #define FLOAT_PRECISION 9
@ -160,12 +163,14 @@ static char *ftoa(char *p, float num, uint32_t precision) {
// Fix rounding error if get // Fix rounding error if get
if (k>=multi){k-=multi;l++;} if (k>=multi){k-=multi;l++;}
p = long_to_string_with_divisor(p, l, 10, 0); p = long_to_string_with_divisor(p, l, 10, 0);
if (precision && k){ if (precision){
*p++ = '.'; *p++ = '.';
p=long_to_string_with_divisor(p, k, 10, precision); p=long_to_string_with_divisor(p, k, 10, precision);
#ifndef CHPRINTF_FORCE_TRAILING_ZEROS
// remove zeros at end // remove zeros at end
while (p[-1]=='0') p--; while (p[-1]=='0') p--;
if (p[-1]=='.') p--; if (p[-1]=='.') p--;
#endif
} }
return p; return p;
} }