<!--
{
  "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/Float/init(nan:signaling:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sf3nan9signalingSfs6UInt32V_Sbtcfc"
  },
  "title" : "init(nan:signaling:)"
}
-->

# init(nan:signaling:)

Creates a NaN (“not a number”) value with the specified payload.

```
init(nan payload: Float.RawSignificand, signaling: Bool)
```

## Parameters

`payload`

The payload to use for the new NaN value.

`signaling`

Pass `true` to create a signaling NaN or `false` to create
a quiet NaN.

## Discussion

NaN values compare not equal to every value, including themselves. Most
operations with a NaN operand produce a NaN result. Don’t use the
equal-to operator (`==`) to test whether a value is NaN. Instead, use
the value’s `isNaN` property.

```
let x = Float(nan: 0, signaling: false)
print(x == .nan)
// Prints "false"
print(x.isNaN)
// Prints "true"
```

---

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)