<html><body>
<p><font size="2" face="sans-serif">Comparing a BFP and a DFP value for equality requires converting one to the other. &nbsp;With BFP to BFP or DFP to DFP, if they are different precisions you can widen the lower precision to match the other. &nbsp;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. &nbsp;Which way should you convert? &nbsp;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.</font><br>
<br>
<font size="2" face="sans-serif">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.</font><br>
<br>
<font size="2" face="sans-serif">- Ian McIntosh &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IBM Canada Lab &nbsp; &nbsp; &nbsp; &nbsp; Compiler Back End Support and Development<br>
</font><br>
<br>
<img width="16" height="16" src="cid:1__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt="Inactive hide details for &quot;Mike Cowlishaw&quot; ---03/18/2013 10:25:11 AM---Just got the attached request from someone implementing "><font size="2" color="#424282" face="sans-serif">&quot;Mike Cowlishaw&quot; ---03/18/2013 10:25:11 AM---Just got the attached request from someone implementing a decimal arithmetic library; I think it's a</font><br>
<br>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>

<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">From:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">&quot;Mike Cowlishaw&quot; &lt;mfc@speleotrove.com&gt;</font></td></tr>

<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>

<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">To:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">&quot;'CFP'&quot; &lt;cfp-interest@ucbtest.org&gt;</font></td></tr>

<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>

<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Date:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">03/18/2013 10:25 AM</font></td></tr>

<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>

<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Subject:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">[Cfp-interest] C operators</font></td></tr>

<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>

<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Sent by:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=0ABBF1A1DFFA04DB8f9e8a93df938@ca.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">cfp-interest-bounces@oakapple.net</font></td></tr>
</table>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
<font size="2" color="#0000FF" face="Arial">Just got the attached request from someone implementing a decimal arithmetic library; I think it's a C/C++ question really. &nbsp;But I'm not sure where to 'point him to'. &nbsp;Any suggestions appreciated.</font><br>
<font size="3" face="serif">&nbsp;</font><br>
<font size="2" color="#0000FF" face="Arial">Mike</font><br>
<font size="3" face="serif">&nbsp;</font><br>
<font size="2" color="#008080" face="Arial">The C++ decimal FP TR defines, well, everything, in terms of IEEE-754.<br>
 Also operations like this: lhs == rhs where lhs or rhs are integers or binary FP types. &nbsp;I am trying to interpret IEEE-754 to see if it indeed defines such operations. &nbsp;(With a quick look I could not find.)</font><br>
<font size="3" face="serif">&nbsp;</font><br>
<font size="2" color="#008080" face="Arial">I have no problem defining the return value, however I am not sure if and what exceptions are to be raised? &nbsp;For example, if I compare a<br>
decimal32 to a double, and the double is larger that dec32_max, should I set overflow? &nbsp;(Because I have tried to convert the double to<br>
dec32.) &nbsp;Or perhaps I should set inexact, because I have tried to convert the Dec32 to double first, and it may not be exactly representable?</font><br>
<font size="3" face="serif">&nbsp;</font><br>
<font size="2" color="#008080" face="Arial">Could you give me a hint on what sections of the IEEE-754 I should read to find out those things? &nbsp;Thanks in advance. &nbsp;Oh, and feel free to tell me if I ask too much.</font><tt><font size="2">_______________________________________________<br>
Cfp-interest mailing list<br>
Cfp-interest@oakapple.net<br>
</font></tt><tt><font size="2"><a href="http://mailman.oakapple.net/mailman/listinfo/cfp-interest">http://mailman.oakapple.net/mailman/listinfo/cfp-interest</a></font></tt><tt><font size="2"><br>
</font></tt><br>
<br>
</body></html>