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

Re: int2interval, frac2interval, rat2interval



> 
> ----- Исходное сообщение -----
> От: vincent@xxxxxxxxxx
> Кому: STDS-1788@xxxxxxxxxxxxxxxxx
> Отправленные: Четверг, 19 Апрель 2012 г 12:38:48 GMT +04:00 Абу-Даби, Маскат
> Тема: Re: int2interval, frac2interval, rat2interval
>
> On 2012-04-18 20:11:14 -0700, Dmitry Nadezhin wrote:
> > 1) Add following items to section 3.2 Definitions of the Level 1
> > text approved by the motion 31.
> > 
> > 3.2.999. integer. Any member of the set Z of integer numbers.
> > 3.2.999. rational. Any member of the set Q of rational numbers.> 
> > 
> > 2) Add following paragraphs to the constructor text approved by the
> > motion 30.
> > 
> > - The constructor int2bareinterval(i) is defined for an integer value i. 
> >  Its value is the singleton interval [i,i] = { i }.
>
> This is not Level 2 yet, but I suppose that what is an integer will be
> language-defined. I mean, it can come from an integer type,

I thought that int2interval(i) is a pattern and
that an implementation may define variants of this operation for any integer type:

short2interval(short s);
int2interval(int i);
long2interval(long l);
mpz2interval(mpz_t z);

or in languages with overloading:

class Interval {
  Interval(short s) {...}
  Interval(int i) {...}
  Interval(long l) {...}
  Interval(BigInteger bi) {...}
}

Each implemented variant must conform P1788 rules.

I missed the question "which of these variants are required ?".
I see 2 ways how to fix them:
a) int2interval(i) and frac2interval(p,q) are also recommended operations (as rat2interval);
b) prepare some rules for int formats (similar to double formats).

My preference is (a).
Does anybody need int2rational(i) or frac2rational(p,q) as required operation ?

> or from some
> floating-point number (if it happens to be an integer) if the language
> doesn't have a specific integer type.

I understand this that constructors
float2interval(float f)
or
Interval(float f)
are allowed but they must throw an exception when f is not exact integer value.
I doesn't seem good for me, because it can't be static typechecked.
Did you mean something other ??

> > - The constructor frac2bareinterval(p,q) is defined for a pair of
> > integer values (p,q) with q > 0.
> >  Its value is the singleton interval [p/q,p/q] = { p/q }.
>
> Why the restriction to q > 0? IMHO, it would be safer to allow
> any q <> 0.

I agree. Thanks.

  -Dima