修正计算float的误差

This commit is contained in:
anod 2023-07-04 22:00:59 +08:00
parent 4392535ee6
commit 4dea86fb47

View File

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