* Added fldiv, flmod, and fldiv-and-mod
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
|
||||
(library (tests fldiv-and-mod)
|
||||
(export test-fldiv-and-mod)
|
||||
(import (ikarus))
|
||||
|
||||
(define (test x1 x2 verify?)
|
||||
(let-values ([(d m) (fldiv-and-mod x1 x2)])
|
||||
(printf "(fldiv-and-mod ~s ~s) = ~s ~s\n" x1 x2 d m)
|
||||
(when verify?
|
||||
(assert (= d (fldiv x1 x2)))
|
||||
(assert (= m (flmod x1 x2)))
|
||||
(assert (<= 0.0 m))
|
||||
(assert (< m (abs x2)))
|
||||
(assert (= x1 (+ (* d x2) m))))))
|
||||
|
||||
(define (test-fldiv-and-mod)
|
||||
(test +17.0 +3.0 #t)
|
||||
(test +17.0 -3.0 #t)
|
||||
(test -17.0 +3.0 #t)
|
||||
(test -17.0 -3.0 #t)
|
||||
(test +16.0 +3.0 #t)
|
||||
(test +16.0 -3.0 #t)
|
||||
(test -16.0 +3.0 #t)
|
||||
(test -16.0 -3.0 #t)
|
||||
(test +15.0 +3.0 #t)
|
||||
(test +15.0 -3.0 #t)
|
||||
(test -15.0 +3.0 #t)
|
||||
(test -15.0 -3.0 #t)
|
||||
(test +17.0 +3.5 #t)
|
||||
(test +17.0 -3.5 #t)
|
||||
(test -17.0 +3.5 #t)
|
||||
(test -17.0 -3.5 #t)
|
||||
(test +16.0 +3.5 #t)
|
||||
(test +16.0 -3.5 #t)
|
||||
(test -16.0 +3.5 #t)
|
||||
(test -16.0 -3.5 #t)
|
||||
(test +15.0 +3.5 #t)
|
||||
(test +15.0 -3.5 #t)
|
||||
(test -15.0 +3.5 #t)
|
||||
(test -15.0 -3.5 #t)
|
||||
(test +17.0 +nan.0 #f)
|
||||
(test -17.0 +nan.0 #f)
|
||||
(test +17.0 +inf.0 #f)
|
||||
(test +17.0 -inf.0 #f)
|
||||
(test -17.0 +inf.0 #f)
|
||||
(test -17.0 -inf.0 #f)))
|
||||
Reference in New Issue
Block a user