Learn about integer and floating-point conversions
Introduction
An introduction to integer and floating-point data types
Integer and floating-point conversions
More on implicit conversions
Data type demotions
Next Steps
Learn about integer and floating-point conversions
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
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.
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.
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.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.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.