---
title: Invalid float cast
framework: xcode
role: article
role_heading: Article
path: xcode/invalid-float-cast
---

# Invalid float cast

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

## Overview

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. 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.

## See Also

### Undefined Behavior Sanitizer

- [Misaligned pointer](xcode/misaligned-pointer.md)
- [Invalid Boolean value](xcode/invalid-boolean.md)
- [Out-of-bounds array access](xcode/out-of-bounds-array-access.md)
- [Invalid enumeration value](xcode/invalid-enumeration-value.md)
- [Reaching of unreachable point](xcode/reaching-of-unreachable-point.md)
- [Dynamic type violation](xcode/dynamic-type-violation.md)
- [Division by zero](xcode/division-by-zero.md)
- [Nonnull argument violation](xcode/nonnull-argument-violation.md)
- [Nonnull return value violation](xcode/nonnull-return-value-violation.md)
- [Nonnull variable assignment violation](xcode/nonnull-variable-assignment-violation.md)
- [Null reference creation and null pointer dereference](xcode/null-reference-creation-and-null-pointer-dereference.md)
- [Invalid object size](xcode/invalid-object-size.md)
- [Invalid shift](xcode/invalid-shift.md)
- [Integer overflow](xcode/integer-overflow.md)
- [Invalid variable-length array](xcode/invalid-variable-length-array.md)
