[Cfp-interest 1700] Re: printf with %a

Jim Thomas jaswthomas at sbcglobal.net
Sun Jul 19 09:33:40 PDT 2020


I don’t disagree, but this doesn’t mean the implementation is required to deliver the better result. Paul is right that the conversion is underspecified. In particular, when a formatting precision is given that isn’t sufficient to represent the precision of the floating type, the set of values in the destination format, hence the result of rounding, is dependent on an implementation-defined method for choosing the most significant digit. Here where the formatting precision is 0, we don’t even know what small integers are in the destination format. If the implementation chooses to always make the MSD be 1, then with formatting precision equal 0, only powers of 2 are representable. However, if the implementation chooses to “normalize” the bits in the MSD, the MSD is between 8 and F and all integers are representable with any formatting precision.

- Jim Thomas

> On Jul 19, 2020, at 8:08 AM, Fred J. Tydeman <tydeman at tybor.com> wrote:
> 
> On Sat, 18 Jul 2020 10:57:51 -0700 Jim Thomas wrote:
>> 
>> This requirement is satisfied by +0x2.p+1 and it is arguably correctly rounded, assuming default rounding direction.
> 
> That has a rounding error and is inexact.
> While, 0x3.p+1 has no error and is exact.
> Both 2 and 3 take two bits before the radix point.
> So, it can do 2, it should be able to do 3.
> 
> 
> 
> ---
> Fred J. Tydeman        Tydeman Consulting
> tydeman at tybor.com      Testing, numerics, programming
> +1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
> Sample C99+FPCE tests: http://www.tybor.com
> Savers sleep well, investors eat well, spenders work forever.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20200719/6c5a8b4a/attachment.htm>


More information about the Cfp-interest mailing list