Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

9 lines
969 B
XML

<?xml version="1.0"?>
<clause number="13" title="Conversions">
<paragraph>A conversion enables an expression of one type to be treated as another type. Conversions can be implicit or explicit, and this determines whether an explicit cast is required. <example>[Example: For instance, the conversion from type <keyword>int</keyword> to type <keyword>long</keyword> is implicit, so expressions of type <keyword>int</keyword> can implicitly be treated as type <keyword>long</keyword>. The opposite conversion, from type <keyword>long</keyword> to type <keyword>int</keyword>, is explicit and so an explicit cast is required. <code_example><![CDATA[
int a = 123;
long b = a; // implicit conversion from int to long
int c = (int) b; // explicit conversion from long to int
]]></code_example>end example]</example> Some conversions are defined by the language. Programs may also define their own conversions (<hyperlink>13.4</hyperlink>). </paragraph>
</clause>