Skip to content

Commit 2c2d170

Browse files
committed
Always print a minimum of 2 digits of exponent
1 parent 428a8b6 commit 2c2d170

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

extra/detail/generate_string.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55
def generate_string(significand, exp, sign):
66
if significand == 0:
7-
result = "0.0e+0"
7+
result = "0e+00"
88
else:
99
sig_str = str(significand)
1010
n_digits = len(sig_str)
11+
1112
if n_digits == 1:
1213
normalized_str = sig_str
1314
total_exp = exp
1415
else:
1516
normalized_str = sig_str[0] + '.' + sig_str[1:]
1617
total_exp = exp + n_digits - 1
17-
result = f"{'-' if sign else ''}{normalized_str}e{total_exp:+}"
18+
19+
result = f"{'-' if sign else ''}{normalized_str}e{total_exp:+03d}"
1820

1921
return result

0 commit comments

Comments
 (0)