[Cfp-interest 1287] Fwd: Re: C++ Standard Floating-Point issues

Ian McIntosh ianmc at eol.ca
Tue Apr 23 08:56:38 PDT 2019


 ----- Original Message -----
              From: Ian McIntosh ianmc at eol.ca
              To: "Hubert Tong" hstong at ca.ibm.com
              Sent: Tue 19/03/19  1:25 PM
              Subject: Fwd: Re: C++ Standard Floating-Point issues
 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 
 I hope all is well with you and the compiler team. 
  - Ian 
 On Mon 19/03/18 10:17 AM , "Hubert Tong" hstong at ca.ibm.com [1] sent:

 > Hi Ian,It's great to hear from you!The 
 > draft version of the C++ Standard is available at
https://wg21.link/std.  FLT_EVAL_METHOD:As a side note, do want to
mention that FLT_EVAL_METHOD is not 
 > really set properly by most vendors. Compilers often have options
that 
 > would change the property that FLT_EVAL_METHOD tries to capture,
but the 
 > value of FLT_EVAL_METHOD is unchanged.C++ has FLT_EVAL_METHOD. It
inherits it through the 
 > C Standard library, and it does not really talk about it 
 > otherwise.Allowance for greater precision and 
 > range: 
 > The values of the floating operands and the results of 
 > floating expressions may be represented in greater precision and
range than 
 > that required by the type; the types are not changed thereby. 
 > [53] 
 > [53] The cast and assignment operators must still 
 > perform their specific conversions as described in 7.6.3, 7.6.1.8
and 
 > 7.6.18.Generally, regarding the 
 > floating-point model and the abstract format of the floating-point
types, 
 > the most restrictive requirements in C++ come from inheriting the
various 
 > macros from C and the definitions from the corresponding
numeric_limits 
 > specialization.Literals: 
 > If the scaled value is in the range of representable 
 > values for its type, the result is the scaled value if
representable, else 
 > the larger or smaller representable value nearest the scaled
value, chosen 
 > in an implementation-defined manner.If the 
 > scaled value is not in the range of representable values for its
type, the 
 > program is ill-formed.Return:This is an initialization in C++, 
 > not an assignment. Promotion preserves the value. Implicit
conversion has 
 > this: 
 >  
 > If the source value can be exactly represented in the 
 > destination type, the result of the conversion is that exact 
 > representation. If the source value is between two adjacent
destination 
 > values, the result of the conversion is an implementation-defined
choice of 
 > either of those values. Otherwise, the behavior is 
 > undefined.Thus (I believe) an expression 
 > whose type is the return type, when evaluated with greater range
and 
 > precision, may retain said range and precision in the context of
the 
 > caller.I believe this is compatible with C.Parameters:This is also
an 
 > initialization in C++, and not an assignment. Unlike C, I believe
C++ would 
 > allow retaining greater range and precision when an expression
whose type 
 > is the type of the function parameter is passed as an argument to
the 
 > function.I hope this 
 > helps.-- HTIan McIntosh ---18-03-2019 09:09:02 
 > a.m.---Hubert: I hope you can help me with some C++ Standard 
 > issues.From:        
 > Ian McIntosh To:        Hubert Tong 
 > Date:    
 >     18-03-2019 09:09 a.m.Subject:        C++ Standard
Floating-Point 
 > issuesHubert:I 
 > hope you can help me with some C++ Standard issues.I'm in the C 
 > Standard's C Floating Point group, and have been asked to look
intosome 
 > ways C might or might not be compatible with C.All relate to in
what 
 > precision some floating-point vaues and expressions are
evaluated.This 
 > became much more difficult when I retired.I've already checked the
Toronto Reference Library and the UofT Library 
 > and Engineering Library,and neither has the C++ Standard.  I can 
 > buy a pdf copy but it will cost over $350.I've attached an MS 
 > Word document of the relevant parts of the C Standard.Here are the

 > questions:1. Does C++ have the "FLT_EVAL_METHOD" macro or 
 > anything equivalent, telling the programin what precision most
floating 
 > expressions are evaluated?  If it does, please include its 
 > details.2. Do the "Real floating types" and the "Usual 
 > arithmetic conversions" or their C++ equivalents say anything 
 > about what precisions the floating types are allowed or required
to be 
 > evaluated in?3. What about floating literals / constants?4. 
 > What about floating return values?5. What about floating function 
 > parameters?If you can help I would really appreciate it. 
 >  If it would be better to meet let me know. - Ian 
 > McIntosh  416-757-4628   ianmc at eol.ca [2][attachment 
 > "FLT_EVAL_METHOD in C.doc" deleted by Hubert Tong/Toronto/IBM] 
 >  
 >  
 >  
 >  
 >  
 >  
 >  
 >  


Links:
------
[1] mailto:hstong at ca.ibm.com
[2] mailto:ianmc at eol.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20190423/318e69a3/attachment.html 


More information about the Cfp-interest mailing list