Skip to content

Commit ddd6ff3

Browse files
committed
Issue justinethier#203 - rational? now handles floats properly
1 parent 74acc3a commit ddd6ff3

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

ChangeLog.markdown

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v3.19.2
2+
--------
3+
4+
Bug Fixes:
5+
6+
- Fixed `rational?` to properly handle floating-point numbers.
7+
18
v3.19.1
29
--------
310

hs-src/Language/Scheme/Numerical.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ isReal _ = return $ Bool False
613613
isRational :: [LispVal] -> ThrowsError LispVal
614614
isRational ([Number _]) = return $ Bool True
615615
isRational ([Rational _]) = return $ Bool True
616-
isRational ([n@(Float _)]) = return $ Bool $ isFloatAnInteger n
617-
-- FUTURE: not quite good enough, could be represented exactly and not an integer
616+
isRational ([Float n]) = return $ Bool $ not $ isInfinite n
618617
isRational _ = return $ Bool False
619618

620619
-- |Predicate to determine if given number is an integer.

husk-scheme.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: husk-scheme
2-
Version: 3.19.1
2+
Version: 3.19.2
33
Synopsis: R5RS Scheme interpreter, compiler, and library.
44
Description:
55
<<https://github.com/justinethier/husk-scheme/raw/master/docs/husk-scheme.png>>

tests/t-numerical-ops.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(assert/equal (real? -2.5+0.1i) #f)
1616
;(assert/equal (real? -2.5+0.0i) #f)
1717
;Issue #14: (assert/equal (real? #e1e103) #t)
18-
; TODO: (assert/equal (rational? 3.5) #t)
18+
(assert/equal (rational? 3.5) #t)
1919
(assert/equal (rational? 6/10) #t)
2020
(assert/equal (rational? 6/3) #t)
2121
(assert/equal (integer? 3+0i) #t)

0 commit comments

Comments
 (0)