[m-rev.] for post-commit review: add new float classification predicates
Julien Fischer
jfischer at opturion.com
Wed Sep 17 16:15:06 AEST 2014
On Wed, Sep 17, 2014 at 3:28 PM, Paul Bone <paul at bone.id.au> wrote:
> On Wed, Sep 17, 2014 at 02:41:42PM +1000, Julien Fischer wrote:
> > diff --git a/library/float.m b/library/float.m
> > index bc263e3..bb3fd2b 100644
> > --- a/library/float.m
> > +++ b/library/float.m
> > @@ -173,36 +181,45 @@
> > %
> > :- pred is_inf(float::in) is semidet.
> >
> > - % Is the floating point number not a number?
> > + % True iff the argument is not-a-number (NaN).
> > %
> > :- pred is_nan(float::in) is semidet.
> >
> > - % Is the floating point number not a number or of infinite
> magnitude?
> > + % True iff the argument is of infinite magnitude or not-a-number
> (NaN).
> > %
> > :- pred is_nan_or_infinite(float::in) is semidet.
> >
> > - % Synonym for is_nan_or_inf/1.
> > + % Synonym for above.
> > %
> > :- pred is_nan_or_inf(float::in) is semidet.
>
> "Synonym for *the* above"
Fixed.
> > @@ -722,6 +739,20 @@ is_infinite(F) :-
> > SUCCESS_INDICATOR = false
> > ").
> >
> > +:- pragma foreign_proc("C",
> > + is_finite(Flt::in),
> > + [will_not_call_mercury, promise_pure, thread_safe,
> will_not_modify_trail,
> > + does_not_affect_liveness],
> > +"
> > + SUCCESS_INDICATOR = MR_is_finite(Flt);
> > +").
> > +
> > +is_finite(F) :-
> > + not is_infinite(F),
> > + not is_nan(F).
> > +
> > +is_zero(0.0).
> > +
>
> I'm no floating point expert, but is -0.0 different from 0.0
Depends what you mean by different.
> and if so do we
> need to test for it explicity or does floating point comparison take care
> of
> this for us?
>
No, IEEE 754 says 0.0 and -0.0 compare as equal.
> @@ -298,6 +298,7 @@
> > ** MR_HAVE_ISINF we have the isinf() function.
> > ** MR_HAVE_ISINFF we have the isinff() function.
> > ** MR_HAVE_FINITE we have the finite() function.
> > +** MR_HAVE_ISFINITE we have the isfinite() function.
> > ** MR_HAVE_FESETROUND we have the fesetround() function.
> > ** MR_HAVE_FMA we have the fma() function.
> > */
>
> The use of tabe and spaces is inconsistent here.
>
No it isn't. (In any case it's just doing what the surrounding lines do)
Thanks for that!
Cheers,
Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20140917/d123f97b/attachment.html>
More information about the reviews
mailing list