[Cfp-interest 1736] Re: footnote about sufficient %a formatting precision

Jim Thomas jaswthomas at sbcglobal.net
Mon Aug 3 15:58:31 PDT 2020


Paul,

It could be >=. But the anchor for the footnote is "if the precision is missing and FLT_RADIX is not a power of 2, then the precision is sufficient to distinguish296) values of type double, …”, so the footnote is about the cases where b is not a power of 2, and (as you mention) the powers can’t be equal in these cases. If b is a power of 2, an exact representation is required. I thought it was slightly better with > instead of >=, since the = case isn’t pertinent.

C2X 7.1.1 says 

"The decimal-point character is the character used by functions that convert floating-point numbers to or from character sequences to denote the beginning of the fractional part of such character sequences.189) It is represented in the text and examples by a period, but may be changed by the setlocale function.

189)The functions that make use of the decimal-point character are the numeric conversion functions (7.22.1, 7.29.4.1) and the formatted input/output functions (7.21.6, 7.29.2).”

So I think decimal-point character is the correct term, albeit a somewhat misleading one.

- Jim

> On Aug 3, 2020, at 4:40 AM, Paul Zimmermann <Paul.Zimmermann at inria.fr> wrote:
> 
>       Hi Jim,
> 
>> Here’s a suggested replacement for footnote 296 to address the issues
>> mentioned in the earlier message (below). 
>> 
>> https://wiki.edg.com/pub/CFP/WebHome/footnote_296_rev.pdf
> 
> shouldn't it be 16^P >= b^p instead? If we have a number with p digits in
> radix b, and want to output it in radix B with P digits, we need
> P >= 1 + p*log(b)/log(B) so that we can recover the input number exactly
> (cf page 177 of Modern Computer Arithmetic). This means B^(P-1) >= b^p.
> Here we have B=2 with P replaced by 4P+1 (4P because in hexadecimal, and
> +1 because of the first hexadecimal digit which has at least one bit), thus
> we get 2^4P >= b^p, i.e., 16^P >= b^p.
> 
> For example, for b=2 and p=4, this yields P=1 instead of P=2 for 16^P > b^p.
> 
> Note that equality can occur only when b is a power of two, say b=2^k.
> If we want to distinguish such a case, then it should be 4P+1 >= pk
> thus 16^P >= b^p/2, which would give P=1 for b=2 and p=5 instead of P=2.
> 
> Also should "the decimal-point character" be "the hexadecimal-point character"?
> 
> Paul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20200803/5ed77ccc/attachment.htm>


More information about the Cfp-interest mailing list