<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;">> Hi Ian,It's great to hear from you!The
</span><br>
<span style="color: red;">> 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. 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;">> really set properly by most vendors. Compilers often have options that
</span><br>
<span style="color: red;">> would change the property that FLT_EVAL_METHOD tries to capture, but the
</span><br>
<span style="color: red;">> value of FLT_EVAL_METHOD is unchanged.C++ has FLT_EVAL_METHOD. It inherits it through the
</span><br>
<span style="color: red;">> C Standard library, and it does not really talk about it
</span><br>
<span style="color: red;">> otherwise.Allowance for greater precision and
</span><br>
<span style="color: red;">> range:
</span><br>
<span style="color: red;">> The values of the floating operands and the results of
</span><br>
<span style="color: red;">> floating expressions may be represented in greater precision and range than
</span><br>
<span style="color: red;">> that required by the type; the types are not changed thereby.
</span><br>
<span style="color: red;">> [53]
</span><br>
<span style="color: red;">> [53] The cast and assignment operators must still
</span><br>
<span style="color: red;">> perform their specific conversions as described in 7.6.3, 7.6.1.8 and
</span><br>
<span style="color: red;">> 7.6.18.Generally, regarding the
</span><br>
<span style="color: red;">> floating-point model and the abstract format of the floating-point types,
</span><br>
<span style="color: red;">> the most restrictive requirements in C++ come from inheriting the various
</span><br>
<span style="color: red;">> macros from C and the definitions from the corresponding numeric_limits
</span><br>
<span style="color: red;">> specialization.Literals:
</span><br>
<span style="color: red;">> If the scaled value is in the range of representable
</span><br>
<span style="color: red;">> values for its type, the result is the scaled value if representable, else
</span><br>
<span style="color: red;">> the larger or smaller representable value nearest the scaled value, chosen
</span><br>
<span style="color: red;">> in an implementation-defined manner.If the
</span><br>
<span style="color: red;">> scaled value is not in the range of representable values for its type, the
</span><br>
<span style="color: red;">> program is ill-formed.Return:This is an initialization in C++,
</span><br>
<span style="color: red;">> not an assignment. Promotion preserves the value. Implicit conversion has
</span><br>
<span style="color: red;">> this:
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">> If the source value can be exactly represented in the
</span><br>
<span style="color: red;">> destination type, the result of the conversion is that exact
</span><br>
<span style="color: red;">> representation. If the source value is between two adjacent destination
</span><br>
<span style="color: red;">> values, the result of the conversion is an implementation-defined choice of
</span><br>
<span style="color: red;">> either of those values. Otherwise, the behavior is
</span><br>
<span style="color: red;">> undefined.Thus (I believe) an expression
</span><br>
<span style="color: red;">> whose type is the return type, when evaluated with greater range and
</span><br>
<span style="color: red;">> precision, may retain said range and precision in the context of the
</span><br>
<span style="color: red;">> caller.I believe this is compatible with C.Parameters:This is also an
</span><br>
<span style="color: red;">> initialization in C++, and not an assignment. Unlike C, I believe C++ would
</span><br>
<span style="color: red;">> allow retaining greater range and precision when an expression whose type
</span><br>
<span style="color: red;">> is the type of the function parameter is passed as an argument to the
</span><br>
<span style="color: red;">> function.I hope this
</span><br>
<span style="color: red;">> helps.-- HTIan McIntosh ---18-03-2019 09:09:02
</span><br>
<span style="color: red;">> a.m.---Hubert: I hope you can help me with some C++ Standard
</span><br>
<span style="color: red;">> issues.From:
</span><br>
<span style="color: red;">> Ian McIntosh To: Hubert Tong
</span><br>
<span style="color: red;">> Date:
</span><br>
<span style="color: red;">> 18-03-2019 09:09 a.m.Subject: C++ Standard Floating-Point
</span><br>
<span style="color: red;">> issuesHubert:I
</span><br>
<span style="color: red;">> hope you can help me with some C++ Standard issues.I'm in the C
</span><br>
<span style="color: red;">> Standard's C Floating Point group, and have been asked to look intosome
</span><br>
<span style="color: red;">> ways C might or might not be compatible with C.All relate to in what
</span><br>
<span style="color: red;">> precision some floating-point vaues and expressions are evaluated.This
</span><br>
<span style="color: red;">> 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;">> and Engineering Library,and neither has the C++ Standard. I can
</span><br>
<span style="color: red;">> buy a pdf copy but it will cost over $350.I've attached an MS
</span><br>
<span style="color: red;">> Word document of the relevant parts of the C Standard.Here are the
</span><br>
<span style="color: red;">> questions:1. Does C++ have the "FLT_EVAL_METHOD" macro or
</span><br>
<span style="color: red;">> anything equivalent, telling the programin what precision most floating
</span><br>
<span style="color: red;">> expressions are evaluated? If it does, please include its
</span><br>
<span style="color: red;">> details.2. Do the "Real floating types" and the "Usual
</span><br>
<span style="color: red;">> arithmetic conversions" or their C++ equivalents say anything
</span><br>
<span style="color: red;">> about what precisions the floating types are allowed or required to be
</span><br>
<span style="color: red;">> evaluated in?3. What about floating literals / constants?4.
</span><br>
<span style="color: red;">> What about floating return values?5. What about floating function
</span><br>
<span style="color: red;">> parameters?If you can help I would really appreciate it.
</span><br>
<span style="color: red;">> If it would be better to meet let me know. - Ian
</span><br>
<span style="color: red;">> McIntosh 416-757-4628 <a href="mailto:ianmc@eol.ca">ianmc@eol.ca</a>[attachment
</span><br>
<span style="color: red;">> "FLT_EVAL_METHOD in C.doc" deleted by Hubert Tong/Toronto/IBM]
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">>
</span><br>
<span style="color: red;">>
</span><br>
<br>
<br>
<br>
<br>
<br>
<BR></HTML>