mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 13:54:09 +08:00
修正计算float的误差
This commit is contained in:
parent
4392535ee6
commit
4dea86fb47
@ -126,7 +126,9 @@ static char* float2str( float f, char out[16] )
|
|||||||
if( f < 0 ) f = -f;
|
if( f < 0 ) f = -f;
|
||||||
f = f - floor(f);
|
f = f - floor(f);
|
||||||
f *= 100;
|
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);
|
ee_snprintf(out, 16, "%d.%02d", s, n);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user