---
title: "init(string:locale:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsdecimalnumber/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.

## Declaration

```swift
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 doc://com.apple.foundation/documentation/Foundation/NSLocale/Key/decimalSeparator) to use to interpret the number in numberValue.

## Discussion

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

### Initializing a Decimal Number

- [init(decimal:)](foundation/nsdecimalnumber/init(decimal:).md)
- [init(mantissa:exponent:isNegative:)](foundation/nsdecimalnumber/init(mantissa:exponent:isnegative:).md)
- [init(string:)](foundation/nsdecimalnumber/init(string:).md)
