<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/UInt128/init(exactly:)-rax0",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s7UInt128V7exactlyABSgx_tcSzRzlufc"
  },
  "title" : "init(exactly:)"
}
-->

# init(exactly:)

Creates a new instance from the given integer, if it can be represented
exactly.

```
init?<T>(exactly source: T) where T : BinaryInteger
```

## Parameters

`source`

A value to convert to this type.

## Discussion

If the value passed as `source` is not representable exactly, the result
is `nil`. In the following example, the constant `x` is successfully
created from a value of `100`, while the attempt to initialize the
constant `y` from `1_000` fails because the `Int8` type can represent
`127` at maximum:

```
let x = Int8(exactly: 100)
// x == Optional(100)
let y = Int8(exactly: 1_000)
// y == nil
```

---

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)