summaryrefslogtreecommitdiff
path: root/module/rnrs/base.scm
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2011-01-26 09:34:02 -0500
committerAndy Wingo <wingo@pobox.com>2011-01-28 12:21:14 +0100
commit7112615f73bf79197832fd044dc7f7d9d94b5325 (patch)
treea3018e7ef176829db77b1ee2988160609d9a58e9 /module/rnrs/base.scm
parentcff5fa3384a097839e4a7ae74307d55bab58e2ba (diff)
downloadguile-7112615f73bf79197832fd044dc7f7d9d94b5325.tar.gz
Implement `finite?' in core and fix R6RS `finite?' and `infinite?'
* libguile/numbers.c (scm_finite_p): Add new predicate `finite?' from R6RS to guile core, which returns #t if and only if its argument is neither infinite nor a NaN. Note that this is not the same as (not (inf? x)) or (not (infinite? x)), since NaNs are neither finite nor infinite. * test-suite/tests/numbers.test: Add test cases for `finite?'. * module/rnrs/base.scm: Import `inf?' as `infinite?' instead of reimplementing it. Previously, the R6RS implementation of `infinite?' did not detect non-real complex infinities, nor did it throw exceptions for non-numbers. (Note that NaNs _are_ considered numbers by scheme, despite their name). Import `finite?' instead of reimplementing it. Previously, the R6RS implementation of `finite?' returned #t for both NaNs and non-real complex infinities, in violation of R6RS. * NEWS: Add NEWS entries, and reorganize existing numerics-related entries together under one subheading. * doc/ref/api-data.texi (Real and Rational Numbers): Add docs for `finite?' and scm_finite_p.
Diffstat (limited to 'module/rnrs/base.scm')
-rw-r--r--module/rnrs/base.scm6
1 files changed, 2 insertions, 4 deletions
diff --git a/module/rnrs/base.scm b/module/rnrs/base.scm
index a6ae1b910..c7579c32e 100644
--- a/module/rnrs/base.scm
+++ b/module/rnrs/base.scm
@@ -1,6 +1,6 @@
;;; base.scm --- The R6RS base library
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -76,6 +76,7 @@
(import (rename (except (guile) error raise)
(quotient div)
(modulo mod)
+ (inf? infinite?)
(exact->inexact inexact)
(inexact->exact exact))
(srfi srfi-11))
@@ -98,9 +99,6 @@
(let ((sym (car syms)))
(and (symbol? sym) (symbol=?-internal (cdr syms) sym)))))
- (define (infinite? x) (or (eqv? x +inf.0) (eqv? x -inf.0)))
- (define (finite? x) (not (infinite? x)))
-
(define (exact-integer-sqrt x)
(let* ((s (exact (floor (sqrt x)))) (e (- x (* s s)))) (values s e)))