<!--
{
  "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/FormatStyle/currency(code:)-1yg68",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11FormatStylePAAE8currency4codeAA013FloatingPointbC0V8CurrencyVyqd___GSS_tAJRszSBRd__lFZ"
  },
  "title" : "currency(code:)"
}
-->

# currency(code:)

Returns a format style to use floating-point currency notation.

```
static func currency<Value>(code: String) -> Self where Self == FloatingPointFormatStyle<Value>.Currency, Value : BinaryFloatingPoint
```

## Parameters

`code`

The currency code to use, such as `EUR` or `JPY`. See ISO-4217 for a list of valid codes.

## Return Value

A floating-point format style that uses the specified currency code.

## Discussion

Use the dot-notation form of this method when the call point allows the use of [`FloatingPointFormatStyle`](/documentation/Foundation/FloatingPointFormatStyle). You typically do this when calling the `formatted` methods of types that conform to <doc://com.apple.documentation/documentation/Swift/BinaryFloatingPoint>.

The following example creates an array of doubles, then uses <doc://com.apple.documentation/documentation/Swift/BinaryFloatingPoint/formatted(_:)-83x4n> and the currency style provided by this method to format the doubles as US dollars:

```swift
let nums: [Double] = [100.01, 1000.02, 10000.03, 100000.04, 1000000.05]
let currencyNums = nums.map { $0.formatted(
    .currency(code:"USD")) } // ["$100.01", "$1,000.02", "$10,000.03", "$100,000.04", "$1,000,000.05"]
```

---

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)