Skip to content

Commit e6a1e03

Browse files
committed
Fix endpoint max and min bugs
1 parent 7e0cdb5 commit e6a1e03

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

mpfr.rkt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124

125125
(define mpfr-trunc! (get-mpfr-fun 'mpfr_trunc (_fun _mpfr-pointer _mpfr-pointer -> _int)))
126126

127+
(define mpfr-min!
128+
(get-mpfr-fun 'mpfr_min (_fun _mpfr-pointer _mpfr-pointer _mpfr-pointer _rnd_t -> _int)))
129+
130+
(define mpfr-max!
131+
(get-mpfr-fun 'mpfr_max (_fun _mpfr-pointer _mpfr-pointer _mpfr-pointer _rnd_t -> _int)))
132+
127133
(define mpfr-cosh! (get-mpfr-fun 'mpfr_cosh (_fun _mpfr-pointer _mpfr-pointer _rnd_t -> _int)))
128134

129135
(define mpfr-init2! (get-mpfr-fun 'mpfr_init2 (_fun _mpfr-pointer _prec_t -> _void)))
@@ -333,6 +339,8 @@
333339
mpfr-ceil!
334340
mpfr-floor!
335341
mpfr-trunc!
342+
mpfr-min!
343+
mpfr-max!
336344
mpfr-log!
337345
mpfr-set-prec!
338346
mpfr-set!

ops/core.rkt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,19 @@
194194
(define (endpoint-min2 e1 e2 rnd)
195195
(match-define (endpoint x x!) e1)
196196
(match-define (endpoint y y!) e2)
197-
(define src (endpoint-val (if (bflte? x y) e1 e2)))
198197
(define out
199198
(parameterize ([bf-precision (bf-precision)])
200199
(bf 0)))
201-
(mpfr-set! out src rnd)
200+
(mpfr-min! out x y rnd)
202201
(endpoint out (or (and (bf=? out x) x!) (and (bf=? out y) y!))))
203202

204203
(define (endpoint-max2 e1 e2 rnd)
205204
(match-define (endpoint x x!) e1)
206205
(match-define (endpoint y y!) e2)
207-
(define src (endpoint-val (if (bfgte? x y) e1 e2)))
208206
(define out
209207
(parameterize ([bf-precision (bf-precision)])
210208
(bf 0)))
211-
(mpfr-set! out src rnd)
209+
(mpfr-max! out x y rnd)
212210
(endpoint out (or (and (bf=? out x) x!) (and (bf=? out y) y!))))
213211

214212
(define (ival-union x y)

0 commit comments

Comments
 (0)