[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 37/69: Build scm_integer_p on scm_is_integer, not vice v
From: |
Andy Wingo |
Subject: |
[Guile-commits] 37/69: Build scm_integer_p on scm_is_integer, not vice versa |
Date: |
Fri, 7 Jan 2022 08:27:11 -0500 (EST) |
wingo pushed a commit to branch wip-inline-digits
in repository guile.
commit 5f4ee3c1315aa7b65470fd1231a155c7f92048c7
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Tue Jan 4 12:01:18 2022 +0100
Build scm_integer_p on scm_is_integer, not vice versa
* libguile/numbers.c: Switch layering of scm_is_integer /
scm_is_exact_integer and their SCM-valued counterparts.
---
libguile/numbers.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 51e5ee19a..46f55de58 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -4605,15 +4605,7 @@ SCM_DEFINE (scm_integer_p, "integer?", 1, 0, 0,
"else return @code{#f}.")
#define FUNC_NAME s_scm_integer_p
{
- if (SCM_I_INUMP (x) || SCM_BIGP (x))
- return SCM_BOOL_T;
- else if (SCM_REALP (x))
- {
- double val = SCM_REAL_VALUE (x);
- return scm_from_bool (!isinf (val) && (val == floor (val)));
- }
- else
- return SCM_BOOL_F;
+ return scm_from_bool (scm_is_integer (x));
}
#undef FUNC_NAME
@@ -4623,10 +4615,7 @@ SCM_DEFINE (scm_exact_integer_p, "exact-integer?", 1, 0,
0,
"else return @code{#f}.")
#define FUNC_NAME s_scm_exact_integer_p
{
- if (SCM_I_INUMP (x) || SCM_BIGP (x))
- return SCM_BOOL_T;
- else
- return SCM_BOOL_F;
+ return scm_from_bool (scm_is_exact_integer (x));
}
#undef FUNC_NAME
@@ -7716,13 +7705,20 @@ SCM_DEFINE (scm_rationalize, "rationalize", 2, 0, 0,
int
scm_is_integer (SCM val)
{
- return scm_is_true (scm_integer_p (val));
+ if (scm_is_exact_integer (val))
+ return 1;
+ if (SCM_REALP (val))
+ {
+ double x = SCM_REAL_VALUE (val);
+ return !isinf (x) && (x == floor (x));
+ }
+ return 0;
}
int
scm_is_exact_integer (SCM val)
{
- return scm_is_true (scm_exact_integer_p (val));
+ return SCM_I_INUMP (val) || SCM_BIGP (val);
}
int
- [Guile-commits] 39/69: Clean up <, reimplement in terms of integer lib, (continued)
- [Guile-commits] 39/69: Clean up <, reimplement in terms of integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 40/69: positive?, negative? use integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 04/69: Implement abs with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 09/69: Implement ceiling-remainder with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 22/69: Implement scm_logand with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 29/69: Reimplement integer-expt in Scheme, Andy Wingo, 2022/01/07
- [Guile-commits] 27/69: Implement scm_lognot with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 26/69: Implement scm_logbit_p with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 25/69: Implement scm_logtest with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 33/69: Integer library takes bignums via opaque struct pointer, Andy Wingo, 2022/01/07
- [Guile-commits] 37/69: Build scm_integer_p on scm_is_integer, not vice versa,
Andy Wingo <=
- [Guile-commits] 36/69: Simplify scm_bigprint, Andy Wingo, 2022/01/07
- [Guile-commits] 38/69: Reimplement = on integer lib, clean up scm_num_eq_p, Andy Wingo, 2022/01/07
- [Guile-commits] 41/69: Simplify implementation of min, max, Andy Wingo, 2022/01/07
- [Guile-commits] 46/69: Clean up scm_divide, Andy Wingo, 2022/01/07
- [Guile-commits] 48/69: Fix scm_integer_to_double_z to always round; clean ups, Andy Wingo, 2022/01/07
- [Guile-commits] 54/69: Remove unused conv-{u,}integer.i.c, Andy Wingo, 2022/01/07
- [Guile-commits] 58/69: Expose frexp from integers lib, Andy Wingo, 2022/01/07
- [Guile-commits] 18/69: Implement round-remainder with new integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 28/69: Implement scm_modulo_expt with new integer library, Andy Wingo, 2022/01/07
- [Guile-commits] 21/69: Implement lcm with new integer lib, Andy Wingo, 2022/01/07