mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 12:20:20 +02:00
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.
This commit is contained in:
parent
2252321bb7
commit
10483f9e64
2 changed files with 7 additions and 3 deletions
|
@ -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)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue