Re: P1788 input/output: exact text representation
Vincent, Michel, P1788
On 2013 Jul 23, at 16:24, Michel Hack wrote:
> Vincent Lefèvre replying to my response concerning exactToInterval() etc:
>>> This is possible only if the recoverable representation includes type
>>> information.
>>
>> No, in either case, you don't need to record type information.
>
> The "possible only" applied to your suggestion of reporting an error
> when recoverableToInterval() was used with the wrong target type.
>
>> (just like when he uses a function, he needs to know the prototype).
>
> In good programming environments the compiler or linker would complain
> about a mismatch. Also remember that recoverable representations are
> often used externally; this matches the case of separately-compiled
> functions, where the responsibility may fall on the linker -- assuming
> the compiler and linker tag external names with a type hash or such.
>
> Michel.
IMO we should Keep It Simple with exact text representation of intervals.
- I don't want to include type information. Let's stick to the case where
the user knows what type to read back to.
- I don't specially wish to specify such a representation for decorated intervals
though it wouldn't be hard.
Let such things wait for a revision of the standard in due course.
However, I think Michel's observation about writing from one type and reading to another is both perceptive and valuable.
Namely suppose type T' is wider than type T, meaning that regarded as sets of mathematical intervals, T is a subset of T'.
Then if
xx is a T-interval
and we write xx out by
s = T-interval2exact(xx).
Michel says string s *should* be readable by T'-exact2interval and recover xx exactly:
yy = T'-exact2interval(s)
should be defined, and should have the same interval value as xx (though of a different type).
E.g. to fix ideas, let T be inf-sup binary32 and T' be inf-sup binary64. Then interval yy should be just xx converted from single to double precision, but
In fact, with the spec as given so far, this happens automatically if T and T' are 754-conforming types. I'm working on writing a suitable "should" statement for general types.
John Pryce