<?xml version="1.0"?>
<clause number="9.4.4.3" title="Real literals">
  <paragraph>Real literals are used to write values of types <keyword>float</keyword>, <keyword>double</keyword>, and <keyword>decimal</keyword>. <grammar_production><name><non_terminal where="9.4.4.3">real-literal</non_terminal></name> :: <rhs><non_terminal where="9.4.4.2">decimal-digits</non_terminal><terminal>.</terminal><non_terminal where="9.4.4.2">decimal-digits</non_terminal><non_terminal where="9.4.4.3">exponent-part</non_terminal><opt/><non_terminal where="9.4.4.3">real-type-suffix</non_terminal><opt/></rhs><rhs><terminal>.</terminal><non_terminal where="9.4.4.2">decimal-digits</non_terminal><non_terminal where="9.4.4.3">exponent-part</non_terminal><opt/><non_terminal where="9.4.4.3">real-type-suffix</non_terminal><opt/></rhs><rhs><non_terminal where="9.4.4.2">decimal-digits</non_terminal><non_terminal where="9.4.4.3">exponent-part</non_terminal><non_terminal where="9.4.4.3">real-type-suffix</non_terminal><opt/></rhs><rhs><non_terminal where="9.4.4.2">decimal-digits</non_terminal><non_terminal where="9.4.4.3">real-type-suffix</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="9.4.4.3">exponent-part</non_terminal></name> :: <rhs><terminal>e</terminal><non_terminal where="9.4.4.3">sign</non_terminal><opt/><non_terminal where="9.4.4.2">decimal-digits</non_terminal></rhs><rhs><terminal>E</terminal><non_terminal where="9.4.4.3">sign</non_terminal><opt/><non_terminal where="9.4.4.2">decimal-digits</non_terminal></rhs></grammar_production><grammar_production><name>sign</name> :: one of <rhs><terminal>+</terminal><terminal>-</terminal></rhs></grammar_production><grammar_production><name><non_terminal where="9.4.4.3">real-type-suffix</non_terminal></name> :: one of <rhs><terminal>F  f  D  d  M  m </terminal></rhs></grammar_production></paragraph>
  <paragraph>If no <non_terminal where="9.4.4.3">real-type-suffix</non_terminal> is specified, the type of the real literal is <keyword>double</keyword>. Otherwise, the <non_terminal where="9.4.4.3">real-type-suffix</non_terminal> determines the type of the real literal, as follows: <list><list_item> A real literal suffixed by F or f is of type <keyword>float</keyword>. <example>[Example: For example, the literals 1f, 1.5f, 1e10f, and 123.456F are all of type <keyword>float</keyword>. end example]</example> </list_item><list_item> A real literal suffixed by D or d is of type <keyword>double</keyword>. <example>[Example: For example, the literals 1d, 1.5d, 1e10d, and 123.456D are all of type <keyword>double</keyword>. end example]</example> </list_item><list_item> A real literal suffixed by M or m is of type <keyword>decimal</keyword>. <example>[Example: For example, the literals 1m, 1.5m, 1e10m, and 123.456M are all of type <keyword>decimal</keyword>. end example]</example> This literal is converted to a <keyword>decimal</keyword> value by taking the exact value, and, if necessary, rounding to the nearest representable value using banker's rounding (<hyperlink>11.1.6</hyperlink>). Any scale apparent in the literal is preserved unless the value is rounded or the value is zero (in which latter case the sign and scale will be 0). <note>[Note: Hence, the literal 2.900m will be parsed to form the <keyword>decimal</keyword> with sign 0, coefficient 2900, and scale 3. end note]</note> </list_item></list></paragraph>
  <paragraph>If the specified literal cannot be represented in the indicated type, a compile-time error occurs. </paragraph>
  <paragraph>The value of a real literal having type <keyword>float</keyword> or <keyword>double</keyword> is determined by using the IEEE &quot;round to nearest&quot; mode. </paragraph>
</clause>
