[m-rev.] for post-commit review: add new float classification predicates

Paul Bone paul at bone.id.au
Wed Sep 17 15:28:54 AEST 2014


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"


> @@ -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 and if so do we
need to test for it explicity or does floating point comparison take care of
this for us?

> diff --git a/runtime/mercury_conf.h.in b/runtime/mercury_conf.h.in
> index 1911cd5..d70d1e5 100644
> --- a/runtime/mercury_conf.h.in
> +++ b/runtime/mercury_conf.h.in
> @@ -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.

The rest seems fine, thanks.


-- 
Paul Bone



More information about the reviews mailing list