<!--
{
  "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/Int/init(_:)-4ekvl",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SZss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufc::SYNTHESIZED::s:Si"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a new instance from the given integer.

```
init<T>(_ source: T) where T : BinaryInteger
```

## Parameters

`source`

A value to convert to this type of integer. The value
passed as `source` must be representable in this type.

## Discussion

Use this initializer to convert from another integer type when you know
the value is within the bounds of this type. Passing a value that can’t
be represented in this type results in a runtime error.

In the following example, the constant `y` is successfully created from
`x`, an `Int` instance with a value of `100`. Because the `Int8` type
can represent `127` at maximum, the attempt to create `z` with a value
of `1000` results in a runtime error.

```
let x = 100
let y = Int8(x)
// y == 100
let z = Int8(x * 10)
// Error: Not enough bits to represent the given value
```

---

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)