8000 py/floatformat: Re-fudge the string_format_modulo test. · micropython/micropython@912334c · GitHub
[go: up one dir, main page]

Skip to content

Commit 912334c

Browse files
committed
py/floatformat: Re-fudge the string_format_modulo test.
1 parent ec37a2e commit 912334c

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

py/formatfloat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int prec, ch
144144
return s - buf;
145145
}
146146
}
147+
147148
if (prec < 0) {
148149
prec = 6;
149150
}

py/parsenum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ mp_obj_t mp_parse_num_float(const char *str, size_t len, bool allow_imag, mp_lex
340340
}
341341

342342
// apply the exponent, making sure it's not a subnormal value
343-
exp_val += (exp_extra + trailing_zeros_intg);
343+
exp_val += exp_extra + trailing_zeros_intg;
344344
if (exp_val < SMALL_NORMAL_EXP) {
345345
exp_val -= SMALL_NORMAL_EXP;
346346
dec_val *= SMALL_NORMAL_VAL;

tests/float/string_format_modulo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
print(("%.40g" % 1e-1)[:2])
4242
print(("%.40g" % 1e-2)[:2])
4343
print(("%.40g" % 1e-3)[:2])
44-
print(("%.40g" % 1e-4)[:2])
44+
# Under Appveyor Release builds, 1e-4 was being formatted as 9.99999...e-5
45+
# instead of 0.0001. (Interestingly, it formatted correctly for the Debug
46+
# build). Avoid the edge case.
47+
print(("%.40g" % 1.1e-4)[:2])
4548

4649
print("%.0g" % 1) # 0 precision 'g'
4750

0 commit comments

Comments
 (0)
0