Skip to content

Commit a0cda9e

Browse files
authored
Merge pull request #113 from herbie-fp/fix-110
Fix pretty subtle "bug" #110 in `fmod`
2 parents 4e74d29 + 5a3b5a2 commit a0cda9e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

eval/tests.rkt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@
102102
; A little hack, the analyze below uses hint from the previous run
103103
; The analyze results must be equal. If not, something wrong has happened
104104
(match-define (list res* hint* converged?*) (rival-analyze machine hyperrect hint))
105-
(check-equal? hint hint*)
106-
(check-equal? res res*)
107-
(check-equal? converged? converged?*)
105+
106+
(with-check-info (['hyperrect hyperrect] ['hint hint])
107+
(check-equal? hint hint*)
108+
(check-equal? res res*)
109+
(check-equal? converged? converged?*))
108110

109111
(for ([_ (in-range number-of-random-pts-per-rect)])
110112
(define pt (sample-pts hyperrect))
111-
(define-values (no-hint-cnt* hint-cnt*) (rival-check-hint machine hint pt))
113+
(define-values (no-hint-cnt* hint-cnt*)
114+
(with-check-info (['pt pt] ['hint hint]) (rival-check-hint machine hint pt)))
112115
(set! hint-cnt (+ hint-cnt hint-cnt*))
113116
(set! no-hint-cnt (+ no-hint-cnt no-hint-cnt*))))
114117
(define skipped-percentage (* (/ hint-cnt no-hint-cnt) 100))
@@ -119,7 +122,9 @@
119122
(define vars '(x y))
120123
(define varc (length vars))
121124
(define machine (rival-compile expressions vars discs))
122-
(define skipped-instr (hints-random-checks machine (first rect) (second rect) varc))
125+
(define skipped-instr
126+
(with-check-info (['expressions expressions])
127+
(hints-random-checks machine (first rect) (second rect) varc)))
123128
(check-true (< skipped-instr 99)
124129
(format "Almost no instructions got skipped by hint at ~a" expressions)))
125130

ops/core.rkt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
(define err (or (or xerr (bflt? xhi lo) (bfgt? xlo hi))))
242242

243243
(if (and (bfzero? lo) (bfzero? xhi))
244-
(ival (endpoint 0.bf xlo!) (endpoint 0.bf xhi!) err? err)
244+
(ival (endpoint (bf 0) xlo!) (endpoint (bf 0) xhi!) err? err)
245245
(ival (endpoint (if (bflt? xlo lo) lo xlo) xlo!)
246246
(endpoint (if (bfgt? xhi hi) hi xhi) xhi!)
247247
err?
@@ -301,7 +301,7 @@
301301
[1 ((monotonic bfabs) x)]
302302
[0
303303
(match-define (ival (endpoint xlo xlo!) (endpoint xhi xhi!) xerr? xerr) x)
304-
(ival (endpoint 0.bf (and xlo! xhi!))
304+
(ival (endpoint (bf 0) (and xlo! xhi!))
305305
(rnd 'up endpoint-max2 (epfn bfabs (ival-lo x)) (ival-hi x))
306306
(ival-err? x)
307307
(ival-err x))]))
@@ -384,10 +384,10 @@
384384
(endpoint (rnd 'up pi.bf) #f)
385385
(or err? (bfgte? (ival-hi-val x) 0.bf))
386386
(or err
387-
(and (bf=? (ival-lo-val x) 0.bf)
388-
(bf=? (ival-hi-val x) 0.bf)
389-
(bf=? (ival-lo-val y) 0.bf)
390-
(bf=? (ival-hi-val y) 0.bf))))]))
387+
(and (bfzero? (ival-lo-val x))
388+
(bfzero? (ival-hi-val x))
389+
(bfzero? (ival-lo-val y))
390+
(bfzero? (ival-hi-val y)))))]))
391391

392392
(define*
393393
ival-cosh

0 commit comments

Comments
 (0)