Skip to content

Decimal.FormatStyle does not always respect the locale's decimalSeparator #135

Open
@StevenSorial

Description

@StevenSorial

Description
Decimal.FormatStyle does not always respect the locale's decimalSeparator, also, the same error occurs with FloatingPointFormatStyle

Steps to reproduce
1- Set the iPhone region to Germany.
2- Set the iPhone language to English (US).
3- Set the Number Format decimal separator to period instead of the default comma.

Expected behavior

    let number: Decimal = 1.5

    let newFormatter = Decimal.FormatStyle.number
    let newResult = number.formatted(newFormatter) // 1,5 ❌

    let oldFormatter = NumberFormatter()
    oldFormatter.numberStyle = .decimal

    let oldResult = oldFormatter.string(from: number as NSNumber)! // 1.5 ✅

IMG_2957 Medium

Environment

  • Swift version: 5.7
  • Xcode version: 14.2
  • Deployment target: iOS 16.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions