Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Formats and parses locale-aware numbers, currencies, percentages, dates, measurements, lists, byte counts, URLs with Foundation FormatStyle.
Use this skill ↓50% 50%0 ptsof checks passed
Scored 50% with the skill and 50% without it.
3 of 3 safety checks passed
Not used yet
Load this reference when concrete formatting modifiers or less common built-in styles are needed.
1234.5.formatted(.number.precision(.fractionLength(0...2)))
1234.5.formatted(.number.precision(.significantDigits(3)))
1234.formatted(.number.rounded(rule: .down, increment: 100))
1_200_000.formatted(.number.notation(.compactName))
42.formatted(.number.notation(.scientific))
(-42).formatted(.number.sign(strategy: .always()))
let amount = Decimal(string: "12345.67")!
amount.formatted(.number)
amount.formatted(.number.grouping(.never))
let parsed = try? Decimal("3.500,63", format: .number.locale(.init(identifier: "de_DE")))
Docs: IntegerFormatStyle · Decimal.FormatStyle
29.99.formatted(.currency(code: "USD"))
Decimal(string: "12345.67")!.formatted(.currency(code: "EUR"))
0.8567.formatted(.percent.precision(.fractionLength(1)))
Next to this one in the catalogue, plus more from the same author.