[Cfp-interest 1725] Re: short hex strings

Jim Thomas jaswthomas at sbcglobal.net
Fri Jul 24 13:10:43 PDT 2020


If we want to have an example of the rounding position issue without getting into the subtleties of the (presumably rare) 1 digit case, something like this might work, inserted before the last sentence in David’s suggested text:

++++++++++
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.
++++++++++

- Jim Thomas

> On Jul 24, 2020, at 8:10 AM, Paul Zimmermann <Paul.Zimmermann at inria.fr> wrote:
> 
>       Hi David,
> 
> for this kind of thing, I find giving a concrete example is very helpful for
> the reader to understand the issue. The initial example where 3 can print as
> 0x2p+1 or 0x3p0 or 0x6p-1 or 0xcp-2 would be nice to add (interestingly, we
> can't have 1 for the first hexadecimal digit, assuming rounding is to nearest).
> 
> Paul
> 
>> Date: Wed, 22 Jul 2020 21:23:17 -0700 (PDT)
>> From: David Hough CFP  <pcfp at oakapple.net>
>> 
>> 
>> "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."
>> 
>> Action item: Come up with a sentence to add to footnote 295 (as per CFP 
>> 1697) to point out the possible numerical differences in output.
>> 
>> I tried making one sentence, but it got complicated and confusing.
>> 
>> Suggestion: add these sentences
>> 
>> This implementation choice affects numerical
>> values printed in short hexadecimal formats that can't 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.    Portable code seeking identical results on
>> different platforms should avoid such short hexadecimal formats.
>> 
>> _______________________________________________
>> Cfp-interest mailing list
>> Cfp-interest at oakapple.net
>> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest




More information about the Cfp-interest mailing list