Skip to content

Commit 91051ef

Browse files
committed
Print values without fraction as integers instead of with trailing .0
1 parent 1431d36 commit 91051ef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

extra/decimal_printer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ def decimal32_summary(valobj, internal_dict):
5050
if significand == 0:
5151
result = "0.0e+0"
5252
else:
53+
# TODO(mborland): Make sure we preserve the amount of precision
5354
n_digits = len(str(abs(significand)))
54-
normalized = significand / (10 ** (n_digits - 1))
55-
total_exp = exp + n_digits - 1
55+
if n_digits > 1:
56+
normalized = significand / (10 ** (n_digits - 1))
57+
total_exp = exp + n_digits - 1
58+
else:
59+
normalized = significand
60+
total_exp = exp
5661
result = f"{'-' if not sign else ''}{normalized}e{total_exp:+}"
5762

5863
return result

0 commit comments

Comments
 (0)