Index: pobysoC-4.0/src/pobyso.c
===================================================================
--- pobysoC-4.0/src/pobyso.c	(revision 146)
+++ pobysoC-4.0/src/pobyso.c	(revision 147)
@@ -39,6 +39,105 @@
   sollya_lib_autoprint(objSo, NULL);
 } /* End pobyso_autoprint. */
 
+/* @see pobyso.h#pobyso_dirty_find_zeros */
+mpfr_t*
+pobyso_dirty_find_zeros_bounds(pobyso_func_exp_t funcExpSo,
+                              mpfr_t lowerBound,
+                              mpfr_t upperBound,
+                              int* zerosCount)
+{
+  pobyso_range_t rangeSo;
+  sollya_obj_t zerosListSo    = NULL;
+  sollya_obj_t* zerosArraySo  = NULL;
+  mpfr_t* zerosArrayMp        = NULL;
+  pobyso_precision_t prec;
+
+  int endEll = 0;
+  int i,j;
+
+  /* Arguments check. */
+  *zerosCount = -1;
+  if (funcExpSo == NULL )
+  {
+    pobyso_error_message("pobyso_dirty_find_zeros",
+                        "NULL_POINTER_ARGUMENT",
+                        "The funcExpSo argument is a NULL pointer");
+    return NULL;
+  }
+  if (mpfr_cmp(lowerBound, upperBound) > 0)
+  {
+    pobyso_error_message("pobyso_dirty_find_zeros",
+                        "INVALID_INTERVAL_ARGUMENT",
+                        "The lower bound is larger than the upper bound");
+    return NULL;
+  }
+  /* Make a range out of the bounds. */
+  rangeSo = sollya_lib_range_from_bounds(lowerBound, upperBound);
+  if (rangeSo == NULL)
+  {
+    return NULL;
+  }
+  zerosListSo = sollya_lib_dirtyfindzeros(funcExpSo, rangeSo);
+  if (zerosListSo == NULL)
+  {
+    return NULL;
+  }
+  sollya_lib_clear_obj(rangeSo);
+  /* Transform the Sollya list into an MPFR list. */
+  if (! sollya_lib_get_list_elements(&zerosArraySo,
+                                      zerosCount,
+                                      &endEll,
+                                      zerosListSo))
+  {
+    sollya_lib_clear_obj(zerosListSo);
+    *zerosCount = -1;
+    return NULL;
+  }
+  sollya_lib_clear_obj(zerosListSo);
+  zerosArrayMp = (mpfr_t*) malloc(*zerosCount * sizeof(mpfr_t));
+  if (zerosArrayMp == NULL)
+  {
+    pobyso_error_message("pobyso_dirty_find_zeros",
+                          "MEMORY_ALLOCATION_ERROR",
+                          "Could not allocate zeroes array");
+    *zerosCount = -1;
+    return NULL;
+  }
+  for (i = 0 ; i < *zerosCount ; i++)
+  {
+    if (! sollya_lib_get_prec_of_constant(&prec, zerosArraySo[i]))
+    {
+      /* Clean up the already allocated MPFRs. */
+      for (j = 0 ; j < i ; j++) mpfr_clear(zerosArrayMp[j]);
+      /* Clean up the zerosArrayMp array itself. */
+      free(zerosArrayMp);
+      /* Clean up what is left in the zerosArraySo. */
+      for (j = i ; j < *zerosCount ; j++) sollya_lib_clear_obj(zerosArraySo[j]);
+      /* Clean up the zerosArraySo array itself. */
+      sollya_lib_free(zerosArraySo);
+      *zerosCount = -1;
+      return NULL;
+    }
+    mpfr_init2(zerosArrayMp[i], prec);
+    if (! sollya_lib_get_constant(zerosArrayMp[i], zerosArraySo[i]))
+    {
+      /* Clean up the already allocated MPFRs. */
+      for (j = 0 ; j <= i ; j++) mpfr_clear(zerosArrayMp[j]);
+      /* Clean up the zerosArrayMp array itself. */
+      free(zerosArrayMp);
+      /* Clean up what is left in the zerosArraySo. */
+      for (j = i ; j < *zerosCount ; j++) sollya_lib_clear_obj(zerosArraySo[j]);
+      /* Clean up the zerosArraySo array itself. */
+      sollya_lib_free(zerosArraySo);
+      *zerosCount = -1;
+      return NULL;
+    }
+    sollya_lib_clear_obj(zerosArraySo[i]);
+  } /* End for i. */
+  sollya_lib_free(zerosArraySo);
+  return zerosArrayMp;
+} /* End pobyso_dirty_find_zeros. */
+
 /* @see pobyso.h#pobyso_evaluate_constant */
 int
 pobyso_evaluate_constant(pobyso_func_exp_t functionSo,
@@ -69,11 +168,14 @@
   /* Function evaluation and checks. */
   argumentSo    = sollya_lib_constant(argumentMp);
   evaluationSo  = sollya_lib_evaluate(functionSo, argumentSo);
+  /* Not needed any more. */
+  //pobyso_autoprint(evaluationSo);
   sollya_lib_clear_obj(argumentSo);
   /* The range case: we return the mean of the bounds. The result
    * is not faithfully rounded. */
   if (sollya_lib_obj_is_range(evaluationSo))
   {
+    //pobyso_autoprint(evaluationSo);
     if (sollya_lib_get_prec_of_range(&evalPrec, evaluationSo))
     {
       mpfr_init2(evaluationTmpMp1, evalPrec);
@@ -90,7 +192,16 @@
         mpfr_clear(evaluationTmpMp1);
         mpfr_clear(evaluationTmpMp2);
         sollya_lib_clear_obj(evaluationSo);
-        return POBYSO_UNFAITHFULL;
+        /* It may happen, in this case, when the bounds are -Infty  and
+         * +Infty, that the average is NaN. */
+        if (mpfr_nan_p(evaluationMp))
+        {
+          return POBYSO_NAN;
+        }
+        else
+        {
+          return POBYSO_UNFAITHFUL;
+        }
       }
       else /* Could not get the values of the bounds. */
       {
@@ -105,7 +216,7 @@
     }
   } /* End the evaluation is a range. */
   /* From now on, we assume that the evaluation is constant. */
-  if (sollya_lib_get_prec_of_range(&evalPrec, evaluationSo))
+  if (sollya_lib_get_prec_of_constant(&evalPrec, evaluationSo))
   {
     mpfr_init2(evaluationTmpMp1, evalPrec);
     if (sollya_lib_get_constant(evaluationTmpMp1, evaluationSo))
@@ -191,12 +302,12 @@
   pobyso_set_verbosity_to(initial_verbosity_level);
   if (test)
   {
-    if(mpfr_number_p(dummy))
+    if(mpfr_number_p(dummy) || mpfr_inf_p(dummy))
     {
       mpfr_clear(dummy);
       return test;
     }
-    else
+    else /* We do not consider NaNs as constants. */
     {
       mpfr_clear(dummy);
       return 0;
