Skip to content

Commit

Permalink
RFC: rewrite a complicated string formatting operation with an fstrin…
Browse files Browse the repository at this point in the history
…g (2/2)
  • Loading branch information
neutrinoceros committed Nov 27, 2024
1 parent ad1849e commit 3f2be22
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/inifix/enotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def encode(r: float, /) -> str:
if not base.strip(".0"):
return "0e0"
max_ndigit = len(base.replace(".", "")) - 1
fmt = f".{max_ndigit}e"
return ENotationIO.simplify(f"{r:{fmt}}")
return ENotationIO.simplify(f"{r:.{max_ndigit}e}")

@staticmethod
def encode_preferential(r: float, /) -> str:
Expand Down

0 comments on commit 3f2be22

Please sign in to comment.