Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Motion P1788/M0017.02:IO



On 2010-06-27 15:43:00 -0400, Michel Hack wrote:
> However, my point to John had been that, just as binary intervals can be
> recovered exactly from decimal text via recovery conversion, it is possible
> to recover decimal intervals exactly from hexadecimal text, even though
> the actual hexadecimal representation is not exact.  (It must of course
> have sufficient precision, which means that the current definition of
> the C format specifier %a, which implies a fixed precision, is inadequate.
> See the P.S. for more on that.)

I disagree because...

[...]
> P.S.  Hexadecimal recovery conversion for decimal formats.
> 
> This function might be subsumed by regular convertToTextInterval()
> in languages/environments that support a "recoverableHex" conversion
> specifier.  The C %a format does not permit a precision specifier, so
[...]

A precision specifier is permitted for %a:

  -- An optional precision that gives the minimum number of digits
     to appear for the d, i, o, u, x, and X conversions, the number
     of digits to appear after the decimal-point character for a, A,
     e, E, f, and F conversions, the maximum number of significant
     digits for the g and G conversions, or the maximum number of
     bytes to be written for s conversions. The precision takes the
     form of a period (.) followed either by an asterisk * (described
     later) or by an optional decimal integer; if only the period is
     specified, the precision is taken as zero. If a precision appears
     with any other conversion specifier, the behavior is undefined.

(from WG14/N1256, i.e. with TC3), but the first digit is not
uniquely specified, so that one may have to choose more precision
than really necessary.

> it must always pick the appropriate one, namely %.13a for binary64
> and %.28a for binary128.  C does not have a definition for %a when
> appplied to DFP input, as it is defined strictly from the binary
> representation (it must start with '0x1.' for normal and '0x0.' for
> subnormal numbers).

C doesn't support DFP yet, but DFP specification is in the WG14/N1312
draft (and this includes changes to %a).

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)