[Cfp-interest 1732] Re: short hex strings

Jim Thomas jaswthomas at sbcglobal.net
Tue Jul 28 16:26:26 PDT 2020


Putting it all together …

295)Binary implementations can choose the hexadecimal digit to the left of the decimal-point character so that subsequent digits align to nibble (4-bit) boundaries. This implementation choice affects numerical values printed with a precision P that is insufficient to represent all values exactly. Implementations with different conventions about the most significant hexadecimal digit will round at different places, affecting the numerical value of the hexadecimal result. For example, possible printed output for the code 

#include <stdio.h>
…
double x = 123.0;
printf("%.1a", x); 

include "0x1.fp+6" and "0xf.6p+3” whose numerical values are 124 and 123, respectively. Portable code seeking identical numerical results on different platforms should avoid precisions P that require rounding.



> On Jul 24, 2020, at 1:55 PM, David Hough CFP <pcfp at oakapple.net> wrote:
> 
>> ++++++++++
> For example, possible printed output for the code 
> 
> #include <stdio.h>
> ג¦
> double x = 123.0;
> printf("%.1a", x); 
> 
> include "0x1.fp+6" and "0xf.6p+3ג whose numerical values are 124 and 123 respectively.
> ++++++++++
> 
> This is simpler.    
> 
> This is also an example of the sort of thing for which we had background
> documents for 754.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20200728/e87ec7ce/attachment-0001.htm>


More information about the Cfp-interest mailing list