guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.2-150-g022dd


From: Mike Gran
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.2-150-g022dda6
Date: Mon, 10 Oct 2011 03:58:40 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=022dda690126d993d82644efeffada1a1ef41123

The branch, stable-2.0 has been updated
       via  022dda690126d993d82644efeffada1a1ef41123 (commit)
      from  b2c4c3e5e315c64a5978d1c5918e9063cd92ada8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 022dda690126d993d82644efeffada1a1ef41123
Author: Mike Gran <address@hidden>
Date:   Sun Oct 9 20:54:37 2011 -0700

    New functions scm_is_exact and scm_is_inexact
    
    * doc/ref/api-data.texi (Exact and Inexact Numbers): doc for scm_is_exact
      and scm_is_inexact
    * libguile/numbers.c (scm_is_exact, scm_is_inexact): new functions
    * libguile/numbers.h: declarations for scm_is_exact and scm_is_inexact
    * test/suite/standalone/test-conversion.c (test_is_exact, test_is_inexact):
      new tests

-----------------------------------------------------------------------

Summary of changes:
 doc/ref/api-data.texi                   |   13 ++++++++++++
 libguile/numbers.c                      |   10 +++++++++
 libguile/numbers.h                      |    2 +
 test-suite/standalone/test-conversion.c |   33 +++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 9825bef..f9b39b6 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -747,12 +747,25 @@ otherwise.
 
 @end deffn
 
address@hidden {C Function} int scm_is_exact (SCM z)
+Return a @code{1} if the number @var{z} is exact, and @code{0}
+otherwise.  This is equivalent to @code{scm_is_true (scm_exact_p (z))}.
+
+An alternate approch to testing the exactness of a number is to 
+use @code{scm_is_signed_integer} or @code{scm_is_unsigned_integer}.
address@hidden deftypefn
+
 @deffn {Scheme Procedure} inexact? z
 @deffnx {C Function} scm_inexact_p (z)
 Return @code{#t} if the number @var{z} is inexact, @code{#f}
 else.
 @end deffn
 
address@hidden {C Function} int scm_is_inexact (SCM z)
+Return a @code{1} if the number @var{z} is inexact, and @code{0}
+otherwise.  This is equivalent to @code{scm_is_true (scm_inexact_p (z))}.
address@hidden deftypefn
+
 @deffn {Scheme Procedure} inexact->exact z
 @deffnx {C Function} scm_inexact_to_exact (z)
 Return an exact number that is numerically closest to @var{z}, when
diff --git a/libguile/numbers.c b/libguile/numbers.c
index b01af9f..e34c60e 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -536,6 +536,11 @@ SCM_PRIMITIVE_GENERIC (scm_exact_p, "exact?", 1, 0, 0,
 }
 #undef FUNC_NAME
 
+int
+scm_is_exact (SCM val)
+{
+  return scm_is_true (scm_exact_p (val));
+}
 
 SCM_PRIMITIVE_GENERIC (scm_inexact_p, "inexact?", 1, 0, 0,
             (SCM x),
@@ -552,6 +557,11 @@ SCM_PRIMITIVE_GENERIC (scm_inexact_p, "inexact?", 1, 0, 0,
 }
 #undef FUNC_NAME
 
+int
+scm_is_inexact (SCM val)
+{
+  return scm_is_true (scm_inexact_p (val));
+}
 
 SCM_PRIMITIVE_GENERIC (scm_odd_p, "odd?", 1, 0, 0, 
             (SCM n),
diff --git a/libguile/numbers.h b/libguile/numbers.h
index d985830..d3a3444 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -165,6 +165,7 @@ typedef struct scm_t_complex
 
 
 SCM_API SCM scm_exact_p (SCM x);
+SCM_API int scm_is_exact (SCM x);
 SCM_API SCM scm_odd_p (SCM n);
 SCM_API SCM scm_even_p (SCM n);
 SCM_API SCM scm_finite_p (SCM x);
@@ -241,6 +242,7 @@ SCM_API SCM scm_real_p (SCM x);
 SCM_API SCM scm_rational_p (SCM z);
 SCM_API SCM scm_integer_p (SCM x);
 SCM_API SCM scm_inexact_p (SCM x);
+SCM_API int scm_is_inexact (SCM x);
 SCM_API SCM scm_num_eq_p (SCM x, SCM y);
 SCM_API SCM scm_less_p (SCM x, SCM y);
 SCM_API SCM scm_gr_p (SCM x, SCM y);
diff --git a/test-suite/standalone/test-conversion.c 
b/test-suite/standalone/test-conversion.c
index 124ae9d..09b74bf 100644
--- a/test-suite/standalone/test-conversion.c
+++ b/test-suite/standalone/test-conversion.c
@@ -1079,6 +1079,37 @@ test_locale_strings ()
 }
 
 static void
+test_is_exact ()
+{
+  if (1 != scm_is_exact (scm_c_eval_string ("3")))
+    {
+      fprintf (stderr, "fail: scm_is_exact (\"3\") = 1\n");
+      exit (EXIT_FAILURE);
+    }
+  if (0 != scm_is_exact (scm_c_eval_string ("3.0")))
+    {
+      fprintf (stderr, "fail: scm_is_exact (\"3.0\") = 0\n");
+      exit (EXIT_FAILURE);
+    }
+}
+
+static void
+test_is_inexact ()
+{
+  if (1 !=scm_is_inexact (scm_c_eval_string ("3.0")))
+    {
+      fprintf (stderr, "fail: scm_is_inexact (\"3.0\") = 1\n");
+      exit (EXIT_FAILURE);
+    }
+  if (0 != scm_is_inexact (scm_c_eval_string ("3")))
+    {
+      fprintf (stderr, "fail: scm_is_inexact (\"3\") = 0\n");
+      exit (EXIT_FAILURE);
+    }
+}
+
+
+static void
 tests (void *data, int argc, char **argv)
 {
   test_is_signed_integer ();
@@ -1091,6 +1122,8 @@ tests (void *data, int argc, char **argv)
   test_from_double ();
   test_to_double ();
   test_locale_strings ();
+  test_is_exact ();
+  test_is_inexact ();
 }
 
 int


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]