fix(fstring): display absolute value of int after sign
This commit is contained in:
@@ -12,6 +12,12 @@ print(f"{c:,._}")
|
|||||||
print(f"{c:_.,}")
|
print(f"{c:_.,}")
|
||||||
|
|
||||||
// Sign
|
// Sign
|
||||||
|
let d1 = 14
|
||||||
|
let d2 = -26
|
||||||
|
print(f"{d1} {d2}")
|
||||||
|
print(f"{d1:+} {d2:+}")
|
||||||
|
print(f"{d1:-} {d2:-}")
|
||||||
|
print(f"{d1: } {d2: }")
|
||||||
|
|
||||||
// Percentage
|
// Percentage
|
||||||
let pts = 19
|
let pts = 19
|
||||||
@@ -19,5 +25,9 @@ let total = 22
|
|||||||
print(f"Correct answers: {pts/total:.2%}")
|
print(f"Correct answers: {pts/total:.2%}")
|
||||||
|
|
||||||
// Precision
|
// Precision
|
||||||
|
print(f"{c:8}")
|
||||||
|
print(f"{c:8.2}")
|
||||||
|
print(f"{c:.2}")
|
||||||
|
print(f"{c:.8}")
|
||||||
|
|
||||||
// Complex
|
// Complex
|
||||||
@@ -87,6 +87,7 @@ class StringFormatter:
|
|||||||
raise PebbleRuntimeError(spec.number.decimal.dot, "Incompatible decimal options with int type.")
|
raise PebbleRuntimeError(spec.number.decimal.dot, "Incompatible decimal options with int type.")
|
||||||
|
|
||||||
sign: str = self.make_sign(value, spec)
|
sign: str = self.make_sign(value, spec)
|
||||||
|
value = abs(value)
|
||||||
string: str = self.format_int_part(value, fmt_type, spec.number.integral.grouping)
|
string: str = self.format_int_part(value, fmt_type, spec.number.integral.grouping)
|
||||||
|
|
||||||
return sign + string
|
return sign + string
|
||||||
|
|||||||
Reference in New Issue
Block a user