<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSDecimalNumber/init(string:locale:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDecimalNumber(im)initWithString:locale:"
  },
  "title" : "init(string:locale:)"
}
-->

# init(string:locale:)

Initializes a decimal number so that its value is equivalent to that in a given numeric string, interpreted using a given locale.

```
convenience init(string numberValue: String?, locale: Any?)
```

## Parameters

`numberValue`

A numeric string.

    Besides digits,     `numberValue`     can include an initial     `+`     or     `–`    ; a single     `E`     or     `e`    , to indicate the exponent of a number in scientific notation; and a single decimal separator character to divide the fractional from the integral part of the number.

`locale`

A dictionary that defines the locale (specifically the [`decimalSeparator`](/documentation/Foundation/NSLocale/Key/decimalSeparator)) to use to interpret the number in `numberValue`.

## Discussion

The locale parameter determines whether the `decimalSeparator` is a period (like in the United States) or a comma (like in France).

The following strings show examples of acceptable values for `numberValue`:

- `2500.6` (or `2500,6`, depending on locale)
- `–2500.6` (or `–2500,6`)
- `–2.5006e3` (or `–2,5006e3`)
- `–2.5006E3` (or `–2,5006E3`)

The following strings are unacceptable:

- `2,500.6`
- `2500 3/5`
- `2.5006x10e3`
- `two thousand five hundred and six tenths`

## See Also

[`+  decimalNumberWithString:locale:`](/documentation/Foundation/NSDecimalNumber/decimalNumberWithString:locale:)

Creates a decimal number whose value is equivalent to that in a given numeric string, interpreted using a given locale.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)