<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FloatingPointParseStrategy",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation26FloatingPointParseStrategyV"
  },
  "title" : "FloatingPointParseStrategy"
}
-->

# FloatingPointParseStrategy

A parse strategy for creating floating-point values from formatted strings.

```
struct FloatingPointParseStrategy<Format> where Format : FormatStyle, Format.FormatInput : BinaryFloatingPoint
```

## Overview

Create an explicit [`FloatingPointParseStrategy`](/documentation/Foundation/FloatingPointParseStrategy) to parse multiple strings according to the same parse strategy. In the following example, `usCurrencyStrategy` is a [`FloatingPointParseStrategy`](/documentation/Foundation/FloatingPointParseStrategy) that uses US dollars and the `en_US` locale’s conventions for number formatting. The example then uses this strategy to parse an array of strings, some of which represent valid US currency values.

```swift
let usCurrencyStrategy: FloatingPointParseStrategy =
FloatingPointFormatStyle<Double>.Currency(code: "USD",
                                          locale: Locale(identifier: "en_US"))
    .parseStrategy
let currencyValues = ["$100.11", "$1,000.22", "$10,000.33", "€100.44"]
let parsedValues = currencyValues.map { try? usCurrencyStrategy.parse($0) } // [Optional(100.11), Optional(1000.22), Optional(10000.33), nil]
```

You don’t need to instantiate a parse strategy variable to parse a single string. Instead, use the <doc://com.apple.documentation/documentation/Swift/BinaryFloatingPoint> initializers that take a source <doc://com.apple.documentation/documentation/Swift/String> and a `format` parameter to parse the string according to the provided [`FormatStyle`](/documentation/Foundation/FormatStyle). The following example parses a string that represents a currency value in US dollars.

```swift
let formattedUSDollars = "$1,234.56"
let parsedUSDollars = try? Double(formattedUSDollars, format: .currency(code: "USD")
    .locale(Locale(identifier: "en_US"))) // 1234.56
```

## Topics

### Creating a floating-point parse strategy

[`init<Value>(format: Format, lenient: Bool)`](/documentation/Foundation/FloatingPointParseStrategy/init(format:lenient:)-5nxey)

Creates a parse strategy instance using the specified floating-point format style.

[`init<Value>(format: Format, lenient: Bool)`](/documentation/Foundation/FloatingPointParseStrategy/init(format:lenient:)-9g6wm)

Creates a parse strategy instance using the specified floating-point currency format style.

[`init<Value>(format: Format, lenient: Bool)`](/documentation/Foundation/FloatingPointParseStrategy/init(format:lenient:)-1nldg)

Creates a parse strategy instance using the specified floating-point percentage format style.

### Parsing strings

[`func parse(String) throws -> Format.FormatInput`](/documentation/Foundation/FloatingPointParseStrategy/parse(_:))

Parses a floating-point string in accordance with this strategy and returns the parsed value.

### Accessing strategy properties

[`var formatStyle: Format`](/documentation/Foundation/FloatingPointParseStrategy/formatStyle)

The format style this strategy uses when parsing strings.

[`var lenient: Bool`](/documentation/Foundation/FloatingPointParseStrategy/lenient)

A Boolean value that indicates whether parsing allows any discrepencies in the expected format.

### Applying date-parsing strategies

### Supporting types

### Default Implementations

[ParseStrategy Implementations](/documentation/Foundation/FloatingPointParseStrategy/ParseStrategy-Implementations)

## Relationships

### Conforms To

[`Copyable`](/documentation/Swift/Copyable)

[`ParseStrategy`](/documentation/Foundation/ParseStrategy)

[`Encodable`](/documentation/Swift/Encodable)

[`Decodable`](/documentation/Swift/Decodable)

[`Escapable`](/documentation/Swift/Escapable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

---

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)