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

Re: Constructor query



P1788

I am really sorry to have raised a topic and then dropped out for nearly 2 weeks. I was laid low by a beastly cold and my remaining energy had to go into my teaching duties at Cardiff. Let me try to get back in the swim.

On 9 Feb 2010, at 19:43, Michel Hack wrote:
> John Pryce wrote:
>>  nums2interval(REAL l, REAL u)   constructs [l,u] if l <= u.
> 
> That's assuming REAL matches the implementation type of intervals.
> In general, "l" would be rounded down and "u" would be rounded up.
> 
> This becomes relevant for num2interval(REAL x) where the result
> might not be a singleton.

Yes. This is a detail that must be agreed in due course. My own view, which follows the principles of the Motion 6 paper (PP013 sect 3.6.4) is that it should return the tightest interval, of the destination format, that contains the interval defined by the mathematical values of l and u. I think this is what you are saying, too. 

So, for instance, num2interval<binary64>(0.1_decimal64), i.e. the binary64 interval hull of the decimal64 number 0.1, (should the implementation choose to support this) would give the smallest double interval containing exact 0.1. 

And num2interval<binary32>(REALMAX_binary64) would have to give [REALMAX_binary32, oo], I guess.

> The other thorny issue is what to do when either l or u is non-finite,
> i.e. Inf or NaN.  Ok, the constraint "l <= u" rules out Inf of the
> wrong sign (as well as NaN, since it is not comparable), so the only
> additional specification that is needed is when l = u = Inf or when
> l = u = -Inf.

If either l or u is NaN, I think it's unambiguous that one returns a notValid interval.

BTW: As far as I can see, notValid behaves exactly like my NaI, except it aims to be faster at run time. All notValid's are identical, and have NO other meaningful attribute values. 

As for infinite l or u, I don't see a problem with, say l=2, u=oo, which gives [2,oo]. But if l=u=oo, I wouldn't want to discuss this much without Siegfried's input, as he has strong views on infinite endpoints.

> I suppose it should also be stated that when exactly one bound is
> infinite, a semibounded interval is constructed, and when both bounds
> are infinite (of the appropriate signs), Entire is constructed.
> 
> Finally, unless the language supports a *proper* Translation-Time Datum
> Type (TTDT), appropriate warnings are needed when these constructors
> are used with literals that do not correspond to exact floating-point
> numbers, such as 0.1 for binary formats:  nums2interval(0.1, 0.2) does
> not contain the value 1/10 (but does contain 2/10).  (Programmers have
> to be reminded to use text2interval("0.1", "0.2") instead.)

I think such things should go in a section on the interface between 1788 and language-standards; which should also contain the output of our dormant Expression Rearrangement subgroup. And that we need to decide, within that section, which parts shall be normative, and which are just recommendations. Do people agree?

John P.