# Learn about integer and floating-point conversions

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/cross-platform/integer-vs-floats/)
- [An introduction to integer and floating-point data types](https://learn.arm.com/learning-paths/cross-platform/integer-vs-floats/introduction-integer-float-types/)
- [Integer and floating-point conversions](https://learn.arm.com/learning-paths/cross-platform/integer-vs-floats/integer-float-conversions/)
- [More on implicit conversions](https://learn.arm.com/learning-paths/cross-platform/integer-vs-floats/implicit-conversions/)
- [Data type demotions](https://learn.arm.com/learning-paths/cross-platform/integer-vs-floats/type-demotion-problems/)
- [Next Steps](https://learn.arm.com/learning-paths/cross-platform/integer-vs-floats/_next-steps/)

## About this Learning Path

|  |  |
| --- | --- |
| Skill level: | Advanced |
| Reading time: | 30 min |
| Last updated: | 04 Aug 2026 |

|  |  |
| --- | --- |
| Author: | Konstantinos Margaritis , VectorCamp<br>[GitHub](https://github.com/markos)<br>[LinkedIn](https://linkedin.com/in/konstantinosmargaritis)<br>[Twitter](https://twitter.com/@freevec1)<br>[vectorcamp.gr](https://vectorcamp.gr/) |
| Arm IP: | [Neoverse](https://support.arm.com/?tab=compute-ip&Product%20Type=Infrastructure%20Processors) [Cortex-A](https://support.arm.com/?tab=compute-ip&Product%20Type=Application%20Processors) |
| Tags: | [Performance and Architecture](https://learn.arm.com/tag/performance-and-architecture) [Linux](https://learn.arm.com/tag/linux) [GCC](https://learn.arm.com/tag/gcc) [Clang](https://learn.arm.com/tag/clang) [Runbook](https://learn.arm.com/tag/runbook) |

### Who is this for?
This is an advanced topic for C/C++ developers who are interested in learning about the intricacies of conversions between floating-point numbers and integers.

### What will you learn?
After completing this Learning Path, you'll be able to perform the following tasks:
- Learn how to identify and fix potential problems in integer/float conversions in C/C++ on Arm

### Prerequisites
Before starting, you'll need the following prerequisites:
- An Arm computer running Linux and a recent version of a C++ compiler (Clang or GCC) installed.

### Summary
You’ll explore how C and C++ convert integers and floating-point values on Arm Linux, and how those conversions affect correctness. You’ll review numeric ranges, compare explicit and implicit conversions, and run short programs that expose integer-division and narrowing pitfalls. You’ll also compare C++ list-initialization diagnostics with C’s permissive behavior, then adjust types or add explicit casts to produce the intended results.

### Frequently asked questions

**How do I build the examples?**
Compile the C source as C and the C++ source as C++ with a recent GCC or Clang on your Arm Linux system. Run the binaries and compare their output. A narrowing diagnostic from the C++ brace-initialization example is expected.

**What result should I expect from the golden ratio program?**
The ratio approaches 1.6180339887… as the Fibonacci index increases. If the output stays at whole numbers or fails to converge, check for integer division and promote one operand to a floating-point type.

**How do I know an implicit conversion is changing my calculation?**
Inspect the operand types in each expression. Two integer operands produce integer arithmetic, so promote one value or cast it to `float` or `double` when you need a fractional result.

**Why does the C++ demotion example behave differently with braces?**
C++ list initialization with braces can diagnose narrowing conversions at compile time, so `float z{w}` can produce a diagnostic. An assignment such as `float y = w` usually compiles and truncates the value at runtime.

**What should I change if the demotion test prints unexpected values?**
Use a wider destination type for intermediate results when you need to preserve range and precision. Add an explicit conversion only when truncation is intentional, then rebuild and recheck the output.
