stmhal: fix single precision float printing error

Fixes #1435.
This commit is contained in:
Dave Hylands 2015-08-31 15:43:31 -07:00 committed by Paul Sokolovsky
parent e79c6b6312
commit 9d6128acdc
2 changed files with 6 additions and 1 deletions

View File

@ -142,7 +142,10 @@ int mp_format_float(float f, char *buf, size_t buf_size, char fmt, int prec, cha
char e_sign_char = '-';
if (num.f < 1.0F && num.f >= 0.9999995F) {
num.f = 1.0F;
first_dig = '1';
if (e > 1) {
// numbers less than 1.0 start with 0.xxx
first_dig = '1';
}
if (e == 0) {
e_sign_char = '+';
}

View File

@ -12,3 +12,5 @@ def test(a):
test(array('f'))
test(array('d'))
print('{:.4f}'.format(array('f', b'\xcc\xcc\xcc=')[0]))