fix(fstring): display absolute value of int after sign

This commit is contained in:
2026-02-07 23:29:47 +01:00
parent 3f0aa44b09
commit d3c6fc0219
2 changed files with 11 additions and 0 deletions

View File

@@ -12,6 +12,12 @@ print(f"{c:,._}")
print(f"{c:_.,}")
// Sign
let d1 = 14
let d2 = -26
print(f"{d1} {d2}")
print(f"{d1:+} {d2:+}")
print(f"{d1:-} {d2:-}")
print(f"{d1: } {d2: }")
// Percentage
let pts = 19
@@ -19,5 +25,9 @@ let total = 22
print(f"Correct answers: {pts/total:.2%}")
// Precision
print(f"{c:8}")
print(f"{c:8.2}")
print(f"{c:.2}")
print(f"{c:.8}")
// Complex

View File

@@ -87,6 +87,7 @@ class StringFormatter:
raise PebbleRuntimeError(spec.number.decimal.dot, "Incompatible decimal options with int type.")
sign: str = self.make_sign(value, spec)
value = abs(value)
string: str = self.format_int_part(value, fmt_type, spec.number.integral.grouping)
return sign + string