Skip to main content

Type Promotion

Definition:
The automatic conversion of a smaller data type into a larger compatible type.


Detailed Explanation

  • Prevents data loss when performing operations between different numeric types.
  • Common in arithmetic expressions.
  • Happens implicitly in many languages.

Example

// Example: int promoted to double // int x = 5; // double y = x; // automatic promotion


⬅ Back