<!--
{
  "documentType" : "article",
  "framework" : "Xcode",
  "identifier" : "/documentation/Xcode/invalid-float-cast",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Invalid float cast"
}
-->

# Invalid float cast

Detects out-of-range casts to, from, or between floating-point types.

## Overview

Use this check to detect out-of-range casts to, from, or between floating-point types. Invalid casts have undefined behavior, and typically yield arbitrary values. These values may differ from platform to platform. Available in Xcode 9 and later.

### Invalid assignment of a double to a float in C

The cast from `n` to `m` results in undefined behavior because the destination type can’t represent its value.

```occ
double n = 10e50;
float m = (float)n; // Error: 10e50 can't be represented as a float.
```

#### Solution

Use a different destination type or avoid the cast altogether.

---

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)