<!--
{
  "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:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDecimalNumber(im)initWithString:"
  },
  "title" : "init(string:)"
}
-->

# init(string:)

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

```
convenience init(string numberValue: String?)
```

## 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. For a listing of acceptable and unacceptable strings, see [`init(string:locale:)`](/documentation/Foundation/NSDecimalNumber/init(string:locale:))    .

## Discussion

Don’t use this initializer if `numberValue` has a fractional part, since the lack of a locale makes handling the decimal separator ambiguous. The separator is a period in some locales (like in the United States) and a comma in others (such as France).

To parse a numeric string with a fractional part, use [`init(string:locale:)`](/documentation/Foundation/NSDecimalNumber/init(string:locale:)) instead. When working with numeric representations with a known format, pass a fixed locale to ensure consistent results independent of the user’s current device settings. For localized parsing that uses the user’s current device settings, pass [`current`](/documentation/Foundation/NSLocale/current).

---

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)