[Cfp-interest] C operators

Mike Cowlishaw mfc at speleotrove.com
Mon Mar 18 12:41:07 PDT 2013


Exactly my opinion, too.   Many thanks.
 
Mike  


  _____  

From: Ian McIntosh [mailto:ianm at ca.ibm.com] 
Sent: 18 March 2013 19:25
To: Mike Cowlishaw
Cc: 'CFP'
Subject: Re: [Cfp-interest] C operators



Comparing a BFP and a DFP value for equality requires converting one to the
other.  With BFP to BFP or DFP to DFP, if they are different precisions you can
widen the lower precision to match the other.  BFP to DFP or DFP to BFP is
troublesome because when the formats are the same size one has a larger exponent
range but the other has more precision.  Which way should you convert?  The
decision was to make the user convert and do a same-base comparison, with the
hope that the user will know more about the application's needs and whether
exponent range or fraction precision is more important than a compiler would.

If you really cared enough you could get a better result by checking whether an
overflow will or won't happen and doing a different conversion and comparison
depending on that.

- Ian McIntosh          IBM Canada Lab         Compiler Back End Support and
Development


Inactive hide details for "Mike Cowlishaw" ---03/18/2013 10:25:11 AM---Just got
the attached request from someone implementing "Mike Cowlishaw" ---03/18/2013
10:25:11 AM---Just got the attached request from someone implementing a decimal
arithmetic library; I think it's a







	From:


"Mike Cowlishaw" <mfc at speleotrove.com>	




	To:


"'CFP'" <cfp-interest at ucbtest.org>	




	Date:


03/18/2013 10:25 AM	




	Subject:


[Cfp-interest] C operators	




	Sent by:


cfp-interest-bounces at oakapple.net	
  _____  




Just got the attached request from someone implementing a decimal arithmetic
library; I think it's a C/C++ question really.  But I'm not sure where to 'point
him to'.  Any suggestions appreciated.
 
Mike
 
The C++ decimal FP TR defines, well, everything, in terms of IEEE-754.
Also operations like this: lhs == rhs where lhs or rhs are integers or binary FP
types.  I am trying to interpret IEEE-754 to see if it indeed defines such
operations.  (With a quick look I could not find.)
 
I have no problem defining the return value, however I am not sure if and what
exceptions are to be raised?  For example, if I compare a
decimal32 to a double, and the double is larger that dec32_max, should I set
overflow?  (Because I have tried to convert the double to
dec32.)  Or perhaps I should set inexact, because I have tried to convert the
Dec32 to double first, and it may not be exactly representable?
 
Could you give me a hint on what sections of the IEEE-754 I should read to find
out those things?  Thanks in advance.  Oh, and feel free to tell me if I ask too
much._______________________________________________
Cfp-interest mailing list
Cfp-interest at oakapple.net
http://mailman.oakapple.net/mailman/listinfo/cfp-interest




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20130318/e2d5908e/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20130318/e2d5908e/attachment.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20130318/e2d5908e/attachment-0001.gif 


More information about the Cfp-interest mailing list