[m-rev.] for review: mercury implementation of string__format

Peter Ross pro at missioncriticalit.com
Mon Nov 25 23:03:37 AEDT 2002


fjh wrote:
> On 22-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > On Fri, Nov 22, 2002 at 10:29:14PM +1100, Fergus Henderson wrote:
> > +++ library/float.m
> > @@ -448,20 +448,12 @@
> >  :- pragma promise_pure(is_nan/1).
> >  :- pragma foreign_proc(c, is_nan(Flt::in),
> >  [will_not_call_mercury, thread_safe], "
> > -#if MR_USE_SINGLE_PREC_FLOAT
> > -  #ifdef MR_HAVE_ISNANF
> > +#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISNANF)
> >  SUCCESS_INDICATOR = isnanf(Flt);
> > -  #else
> > -    #error ""isnanf not available. Delete this line if not IEEE fp
system.""
> > - SUCCESS_INDICATOR = MR_FALSE;
> > -  #endif
> > +#elif defined(MR_HAVE_ISNAN)
> > + SUCCESS_INDICATOR = isnan((double) Flt);
>
> There's no need for an explicit cast there.
> Standard C guarantees that `float' will get promoted to double,
> even if there is no prototype for isnan() in scope.
>
> Explicit casts can suppress real errors,
> e.g. if `Flt' happened to have type `double *',
> so it's better to avoid them if they are not needed.
>
Done.

> > @@ -478,20 +470,12 @@
> >  :- pragma promise_pure(is_inf/1).
> >  :- pragma foreign_proc(c, is_inf(Flt::in),
> >  [will_not_call_mercury, thread_safe], "
> > -#if MR_USE_SINGLE_PREC_FLOAT
> > -  #ifdef MR_HAVE_ISINFF
> > +#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISINFF)
> >  SUCCESS_INDICATOR = isinff(Flt);
> > -  #else
> > -    #error ""isinff not available. Delete this line if not IEEE fp
system.""
> > - SUCCESS_INDICATOR = MR_FALSE;
> > -  #endif
> > +#elif defined(MR_HAVE_ISINF)
> > + SUCCESS_INDICATOR = isinf((double) Flt);
>
> Likewise here.
>
Done.

> >  #else
> > -  #ifdef MR_HAVE_ISINF
> > - SUCCESS_INDICATOR = isinf(Flt);
> > -  #else
> > -    #error ""isinf not available. Delete this line if not IEEE fp
system.""
> > - SUCCESS_INDICATOR = MR_FALSE;
> > -  #endif
> > + SUCCESS_INDICATOR = (Flt == Flt * 2.0 && Flt != 0.0);
> >  #endif
> >  ").
>
> On second thoughts, it's probably better to use
>
> SUCCESS_INDICATOR = (Flt == Flt / 2.0 && Flt != 0.0);
> ^
>
Done.

I have now checked this in.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.419 / Virus Database: 235 - Release Date: 11/17/2002

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list