Re: P1788 input/output
Ned Nedialkow suggested:
> What about
> interval2text(x, formatstring, string1, string2)
> ...
> string1 and string2 represent the left and right bounds rounded correctly.
> Then the user can do whatever wants with them.
This needs no special functions in a 754-2008 compliant system. It is
equivalent to two sprintf() invocations, one rounding up and the other
rounding down.
> In C we have printf, sprintf, scanf, etc. They are all very well established.
> When reading or writing numbers, they are rounded to the nearest.
Unfortunately few environments comply with the 754-2008 requirement that
there be numeric-to-string conversions that honour a current rounding mode.
Note that the ISO/IEC 9899:201x draft (N1539) for C does require that the
current rounding mode be honoured: Clause F.5, Binary-decimal conversion.
> For example, if [a,b] is an interval, I may write
> printf_i("%fD %fU", a,b);
> so a is rounded down and b is rounded up.
The idea of attaching the rounding directive to the format specifier
is nice. If this could be worked into the current printf syntax there
would be no need for a separate set of functions. But this is a language
issue (when that includes standard run-time functions), and not a P1788
issue. P1788 already requires that the environment provide operations
that honour a given rounding direction, so the primitives should be there.
Michel.
---Sent: 2013-06-28 18:20:31 UTC