Chapter 8. Conversions and Promotions

Table of Contents

8.1. Widening Primitive Conversions
8.2. Binary Floating-Point Promotion

Every expression written in the XL programming language has a compile-time type that can be deduced from the expression. By a conversion from type S to type T, an expression of type S can be treated as having the compile-time type T.

The Java programming language defines several categories of conversions: Identity conversions, widening primitive conversions, narrowing primitive conversions, widening reference conversions, narrowing reference conversions, string conversions, and value set conversions. These conversions occur in several conversion contexts: Assignment conversion, method invocation conversion, casting conversion, string conversion, and unary and binary numeric promotion.

The XL programming language modifies the definition of widening primitive conversions in order to allow for an implicit conversion from double to float and adds the conversion context of binary floating-point promotion (Section 8.2, “Binary Floating-Point Promotion”), which is exclusively used for the exponentiation operator.

8.1. Widening Primitive Conversions

The widening primitive conversions of the XL programming language are the following conversions:

  • byte to short, int, long, float, or double

  • short to int, long, float, or double

  • char to int, long, float, or double

  • int to long, float, or double

  • long to float or double

  • float to double

  • double to float, but only if this is enabled by a corresponding compiler option.