修复浮点数为xxx.999这种输入的字符串转换问题

This commit is contained in:
anod 2023-07-07 12:30:40 +08:00
parent c8a1d11408
commit a30575b935

View File

@ -128,7 +128,12 @@ static char* float2str( float f, char out[16] )
f *= 100; f *= 100;
int n = floor(f); int n = floor(f);
f = f - n; f = f - n;
if( f > 0.5 ) ++n; if( f > 0.5) ++n;
if( n == 100 )
{
++s;
n = 0;
}
ee_snprintf(out, 16, "%d.%02d", s, n); ee_snprintf(out, 16, "%d.%02d", s, n);
return out; return out;
} }