<!--
{
  "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(_:)-8vbwo",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SiySiSdcfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates an integer from the given floating-point value, rounding toward
zero.

```
init(_ source: Double)
```

## Parameters

`source`

A floating-point value to convert to an integer.
`source` must be representable in this type after rounding toward
zero.

## Discussion

Any fractional part of the value passed as `source` is removed, rounding
the value toward zero.

```
let x = Int(21.5)
// x == 21
let y = Int(-21.5)
// y == -21
```

If `source` is outside the bounds of this type after rounding toward
zero, a runtime error may occur.

```
let z = UInt(-21.5)
// Error: ...the result would be less than UInt.min
```

---

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)