<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/numericCast(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s11numericCastyq_xSzRzSzR_r0_lF"
  },
  "title" : "numericCast(_:)"
}
-->

# numericCast(_:)

Returns the given integer as the equivalent value in a different integer
type.

```
func numericCast<T, U>(_ x: T) -> U where T : BinaryInteger, U : BinaryInteger
```

## Parameters

`x`

The integer to convert, an instance of type `T`.

## Return Value

The value of `x` converted to type `U`.

## Discussion

Calling the `numericCast(_:)` function is equivalent to calling an
initializer for the destination type. `numericCast(_:)` traps on overflow
in `-O` and `-Onone` builds.

---

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)