From c6ad6781744e1188e3457c74c387124829a08104 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Fri, 26 Feb 2010 09:12:20 +0000 Subject: [PATCH] some more tests. --- C/arith1.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/C/arith1.c b/C/arith1.c index 52fbc0217..86ab48c31 100644 --- a/C/arith1.c +++ b/C/arith1.c @@ -463,6 +463,17 @@ eval1(Int fi, Term t) { case db_ref_e: RERROR(); } +#if HAVE_ISNAN + if (isnan(dbl)) { + return Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); + } +#endif +#if HAVE_ISNAN + if (isinf(dbl)) { + return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ +(%f)",dbl); + } +#endif RBIG_FL(floor(dbl)); } case op_ceiling: @@ -490,6 +501,17 @@ eval1(Int fi, Term t) { case db_ref_e: RERROR(); } +#if HAVE_ISNAN + if (isnan(dbl)) { + return Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); + } +#endif +#if HAVE_ISNAN + if (isinf(dbl)) { + return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ +(%f)",dbl); + } +#endif RBIG_FL(ceil(dbl)); } case op_round: @@ -517,6 +539,17 @@ eval1(Int fi, Term t) { #endif RERROR(); } +#if HAVE_ISNAN + if (isnan(dbl)) { + return Yap_ArithError(DOMAIN_ERROR_OUT_OF_RANGE, t, "integer(%f)", dbl); + } +#endif +#if HAVE_ISNAN + if (isinf(dbl)) { + return Yap_ArithError(EVALUATION_ERROR_INT_OVERFLOW, MkFloatTerm(dbl), "integer\ +(%f)",dbl); + } +#endif RBIG_FL(my_rint(dbl)); } case op_truncate: