Hi,<br><br>The LangRef says this about fptrunc:<br><br>  "The ‘fptrunc‘ instruction truncates a value from a larger floating point type to a smaller floating point type. If the value cannot fit within the destination type, ty2, then the results are undefined."<br>
<br>What does it mean for the value to "fit within the destination type"? For instance, is the value of<div><br></div><div>  %Inf = fptrunc double 0x7FF0000000000000 to float</div><div><br></div><div>defined? This happens to be folded to a float infinity right now.</div>
<div><br></div><div>The LangRef gives this as an example:</div><div><br></div><div><div>  %Y = fptrunc double 1.0E+300 to float      ; yields undefined</div></div><div><br></div><div>but this is incompatible with C11 Annex F (IEC 60559 floating-point arithmetic), which says:</div>
<div><br></div><div>  "Since negative and positive infinity are representable in IEC 60559 formats, all real numbers lie within the range of representable values."</div><div><br></div><div>This implicitly makes all float-to-float conversions have defined behavior in a C11 implementation which follows Annex F, since the value is always within the range of representable values of the destination type.</div>
<div><br></div><div>So... is the result of fptrunc in this situation really undefined, and should it be? How should it behave on Infs and NaNs?</div><div><br></div><div>Thanks!</div><div>Richard</div>