summaryrefslogtreecommitdiff
path: root/libguile/hash.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-05-08 16:05:27 +0200
committerAndy Wingo <wingo@pobox.com>2011-05-08 16:07:10 +0200
commit10483f9e6491c8b96167a794115bb4829742f9a6 (patch)
treebeda9aa7411547edf25f69d05ffb819f4cfb54da /libguile/hash.c
parent2252321bb77fe83d98d5bcc9db1c76b914e9dd6a (diff)
downloadguile-10483f9e6491c8b96167a794115bb4829742f9a6.tar.gz
fix `hash' for inf and nan
* libguile/hash.c (scm_hasher): Fix to work on inf and nan. * test-suite/tests/hash.test ("hash"): Add tests.
Diffstat (limited to 'libguile/hash.c')
-rw-r--r--libguile/hash.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libguile/hash.c b/libguile/hash.c
index 0dcd1c29e..8448c7ce9 100644
--- a/libguile/hash.c
+++ b/libguile/hash.c
@@ -26,6 +26,7 @@
#include <wchar.h>
#endif
+#include <math.h>
#include <unistr.h>
#include "libguile/_scm.h"
@@ -192,7 +193,7 @@ scm_hasher(SCM obj, unsigned long n, size_t d)
case scm_tc16_real:
{
double r = SCM_REAL_VALUE (obj);
- if (floor (r) == r)
+ if (floor (r) == r && !isinf (r) && !isnan (r))
{
obj = scm_inexact_to_exact (obj);
return scm_to_ulong (scm_modulo (obj, scm_from_ulong (n)));