<HTML>
<span style="font-weight: bold;">----- Original Message -----<br>

                    From: Ian McIntosh ianmc@eol.ca<br>

                    To: "Hubert Tong" hstong@ca.ibm.com<br>

                    Sent: Tue 19/03/19  1:25 PM<br>

                    Subject: Fwd: Re: C++ Standard Floating-Point issues<br>

<br>

<hi></hi></span>Thank you!  That was very helpful.  After I have reread it more carefully and read what the standard says, I may have more questions but I don't expect to.4
<br>



<br>


I hope all is well with you and the compiler team.
<br>



<br>


 - Ian
<br>



<br>


On Mon 19/03/18 10:17 AM , "Hubert Tong" <a href="mailto:hstong@ca.ibm.com">hstong@ca.ibm.com</a> sent:
<br>


<span style="color: red;">&gt; Hi Ian,It's great to hear from you!The
</span><br>


<span style="color: red;">&gt; draft version of the C++ Standard is available at <a target="_blank" href="https://wg21.link/std"><span style="color: red;">https://wg21.link/std.&nbsp; FLT_EVAL_METHOD:As</span></a> a side note, do want to mention that FLT_EVAL_METHOD is not
</span><br>


<span style="color: red;">&gt; really set properly by most vendors. Compilers often have options that
</span><br>


<span style="color: red;">&gt; would change the property that FLT_EVAL_METHOD tries to capture, but the
</span><br>


<span style="color: red;">&gt; value of FLT_EVAL_METHOD is unchanged.C++ has FLT_EVAL_METHOD. It inherits it through the
</span><br>


<span style="color: red;">&gt; C Standard library, and it does not really talk about it
</span><br>


<span style="color: red;">&gt; otherwise.Allowance for greater precision and
</span><br>


<span style="color: red;">&gt; range:
</span><br>


<span style="color: red;">&gt; The values of the floating operands and the results of
</span><br>


<span style="color: red;">&gt; floating expressions may be represented in greater precision and range than
</span><br>


<span style="color: red;">&gt; that required by the type; the types are not changed thereby.
</span><br>


<span style="color: red;">&gt; [53]
</span><br>


<span style="color: red;">&gt; [53] The cast and assignment operators must still
</span><br>


<span style="color: red;">&gt; perform their specific conversions as described in 7.6.3, 7.6.1.8 and
</span><br>


<span style="color: red;">&gt; 7.6.18.Generally, regarding the
</span><br>


<span style="color: red;">&gt; floating-point model and the abstract format of the floating-point types,
</span><br>


<span style="color: red;">&gt; the most restrictive requirements in C++ come from inheriting the various
</span><br>


<span style="color: red;">&gt; macros from C and the definitions from the corresponding numeric_limits
</span><br>


<span style="color: red;">&gt; specialization.Literals:
</span><br>


<span style="color: red;">&gt; If the scaled value is in the range of representable
</span><br>


<span style="color: red;">&gt; values for its type, the result is the scaled value if representable, else
</span><br>


<span style="color: red;">&gt; the larger or smaller representable value nearest the scaled value, chosen
</span><br>


<span style="color: red;">&gt; in an implementation-defined manner.If the
</span><br>


<span style="color: red;">&gt; scaled value is not in the range of representable values for its type, the
</span><br>


<span style="color: red;">&gt; program is ill-formed.Return:This is an initialization in C++,
</span><br>


<span style="color: red;">&gt; not an assignment. Promotion preserves the value. Implicit conversion has
</span><br>


<span style="color: red;">&gt; this:
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; If the source value can be exactly represented in the
</span><br>


<span style="color: red;">&gt; destination type, the result of the conversion is that exact
</span><br>


<span style="color: red;">&gt; representation. If the source value is between two adjacent destination
</span><br>


<span style="color: red;">&gt; values, the result of the conversion is an implementation-defined choice of
</span><br>


<span style="color: red;">&gt; either of those values. Otherwise, the behavior is
</span><br>


<span style="color: red;">&gt; undefined.Thus (I believe) an expression
</span><br>


<span style="color: red;">&gt; whose type is the return type, when evaluated with greater range and
</span><br>


<span style="color: red;">&gt; precision, may retain said range and precision in the context of the
</span><br>


<span style="color: red;">&gt; caller.I believe this is compatible with C.Parameters:This is also an
</span><br>


<span style="color: red;">&gt; initialization in C++, and not an assignment. Unlike C, I believe C++ would
</span><br>


<span style="color: red;">&gt; allow retaining greater range and precision when an expression whose type
</span><br>


<span style="color: red;">&gt; is the type of the function parameter is passed as an argument to the
</span><br>


<span style="color: red;">&gt; function.I hope this
</span><br>


<span style="color: red;">&gt; helps.-- HTIan McIntosh ---18-03-2019 09:09:02
</span><br>


<span style="color: red;">&gt; a.m.---Hubert: I hope you can help me with some C++ Standard
</span><br>


<span style="color: red;">&gt; issues.From:       
</span><br>


<span style="color: red;">&gt; Ian McIntosh To:        Hubert Tong
</span><br>


<span style="color: red;">&gt; Date:   
</span><br>


<span style="color: red;">&gt;     18-03-2019 09:09 a.m.Subject:        C++ Standard Floating-Point
</span><br>


<span style="color: red;">&gt; issuesHubert:I
</span><br>


<span style="color: red;">&gt; hope you can help me with some C++ Standard issues.I'm in the C
</span><br>


<span style="color: red;">&gt; Standard's C Floating Point group, and have been asked to look intosome
</span><br>


<span style="color: red;">&gt; ways C might or might not be compatible with C.All relate to in what
</span><br>


<span style="color: red;">&gt; precision some floating-point vaues and expressions are evaluated.This
</span><br>


<span style="color: red;">&gt; became much more difficult when I retired.I've already checked the Toronto Reference Library and the UofT Library
</span><br>


<span style="color: red;">&gt; and Engineering Library,and neither has the C++ Standard. &nbsp;I can
</span><br>


<span style="color: red;">&gt; buy a pdf copy but it will cost over $350.I've attached an MS
</span><br>


<span style="color: red;">&gt; Word document of the relevant parts of the C Standard.Here are the
</span><br>


<span style="color: red;">&gt; questions:1. Does C++ have the "FLT_EVAL_METHOD" macro or
</span><br>


<span style="color: red;">&gt; anything equivalent, telling the programin what precision most floating
</span><br>


<span style="color: red;">&gt; expressions are evaluated? &nbsp;If it does, please include its
</span><br>


<span style="color: red;">&gt; details.2. Do the "Real floating types" and the "Usual
</span><br>


<span style="color: red;">&gt; arithmetic conversions" or their C++ equivalents say anything
</span><br>


<span style="color: red;">&gt; about what precisions the floating types are allowed or required to be
</span><br>


<span style="color: red;">&gt; evaluated in?3. What about floating literals / constants?4.
</span><br>


<span style="color: red;">&gt; What about floating return values?5. What about floating function
</span><br>


<span style="color: red;">&gt; parameters?If you can help I would really appreciate it.
</span><br>


<span style="color: red;">&gt; &nbsp;If it would be better to meet let me know. - Ian
</span><br>


<span style="color: red;">&gt; McIntosh&nbsp; 416-757-4628 &nbsp; <a href="mailto:ianmc@eol.ca">ianmc@eol.ca</a>[attachment
</span><br>


<span style="color: red;">&gt; "FLT_EVAL_METHOD in C.doc" deleted by Hubert Tong/Toronto/IBM]
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; 
</span><br>


<span style="color: red;">&gt; 
</span><br>



<br>



<br>



<br>


<br>


<br>


<BR></HTML>