Skip to content

Commit cd5656f

Browse files
committed
Fix bug with copysign movability flags
1 parent ab743e1 commit cd5656f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ops/core.rkt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,15 @@
678678
;; 0 is both positive and negative because we don't handle signed zero well
679679
(define can-neg (or (= (mpfr-sign (ival-lo-val y)) -1) can-zero))
680680
(define can-pos (or (= (mpfr-sign (ival-hi-val y)) 1) can-zero))
681+
(define sign-immovable? (and can-neg can-pos (ival-lo-fixed? y) (ival-hi-fixed? y)))
681682
(define err? (or (ival-err? y) xerr?))
682683
(define err (or (ival-err y) xerr))
683684
(match* (can-neg can-pos)
684-
[(#t #t) (ival (rnd 'down epunary bfneg xhi) (rnd 'up epunary bfcopy xhi) err? err)]
685+
[(#t #t)
686+
(define out (ival (rnd 'down epunary bfneg xhi) (rnd 'up epunary bfcopy xhi) err? err))
687+
(if sign-immovable?
688+
out
689+
(ival-mobilize out))]
685690
[(#t #f) (ival (rnd 'down epunary bfneg xhi) (rnd 'up epunary bfneg xlo) err? err)]
686691
[(#f #t) (ival xlo xhi err? err)]
687692
[(#f #f)

0 commit comments

Comments
 (0)