Fixed a bug with exact complexes.

This commit is contained in:
Vincent St-Amour 2010-07-25 22:01:50 -04:00
parent 7cdb5787e5
commit 4803eafa67
4 changed files with 28 additions and 2 deletions

View File

@ -0,0 +1,5 @@
#lang typed/scheme #:optimize
(require racket/unsafe/ops)
(+ 1.0+2.0i 2+4i)

View File

@ -0,0 +1,14 @@
#lang racket
(require racket/unsafe/ops)
(let* ((unboxed-gensym-1 1.0+2.0i)
(unboxed-gensym-2 (unsafe-flreal-part unboxed-gensym-1))
(unboxed-gensym-3 (unsafe-flimag-part unboxed-gensym-1))
(unboxed-gensym-4 2+4i)
(unboxed-gensym-5 (exact->inexact (real-part unboxed-gensym-4)))
(unboxed-gensym-6 (exact->inexact (imag-part unboxed-gensym-4)))
(unboxed-gensym-7 (unsafe-fl+ unboxed-gensym-2 unboxed-gensym-5))
(unboxed-gensym-8 (unsafe-fl+ unboxed-gensym-3 unboxed-gensym-6)))
(unsafe-make-flrectangular unboxed-gensym-7 unboxed-gensym-8))
(void)

View File

@ -0,0 +1,5 @@
#lang typed/scheme
(require racket/unsafe/ops)
(+ 1.0+2.0i 2+4i)

View File

@ -254,11 +254,13 @@
#`((real-binding (exact->inexact #,((optimize) #'e)))))
(pattern e:expr
#:when (isoftype? #'e -Number) ; complex, maybe exact, maybe not
#:with e* (unboxed-gensym)
#:with real-binding (unboxed-gensym)
#:with imag-binding (unboxed-gensym)
#:with (bindings ...)
#`((real-binding (real-part #,((optimize) #'e)))
(imag-binding (imag-part #,((optimize) #'e)))))
#`((e* #,((optimize) #'e))
(real-binding (exact->inexact (real-part e*)))
(imag-binding (exact->inexact (imag-part e*)))))
(pattern e:expr
#:with (bindings ...)
(error "non exhaustive pattern match")