From f2b9a8fe2c8f88dc62f75aa1b79b082fd1fee184 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Wed, 11 Aug 2010 20:00:01 -0400 Subject: [PATCH] Documented TR's behavior when mixing exactness. original commit: cf692e986d2a3690260884d929daae321d21eeb3 --- collects/typed-scheme/scribblings/optimization.scrbl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/collects/typed-scheme/scribblings/optimization.scrbl b/collects/typed-scheme/scribblings/optimization.scrbl index 4f82a1ab..0431cfdc 100644 --- a/collects/typed-scheme/scribblings/optimization.scrbl +++ b/collects/typed-scheme/scribblings/optimization.scrbl @@ -58,6 +58,14 @@ Thus, to get the most of Typed Racket's optimizer, you should use the floating-point literals instead of exact literals when doing floating-point computations. +When mixing floating-point numbers and exact reals in arithmetic +operations, the result is not necessarily a @racket[Float]. For +instance, the result of @racket[(* 2.0 0)] is @racket[0] which is not +a @racket[Float]. This can result in missed optimizations. To prevent +this, when mixing floating-point numbers and exact reals, coerce exact +reals to floating-point numbers using @racket[exact->inexact]. This is +not necessary when using @racket[+] or @racket[-]. + On a similar note, the @racket[Inexact-Complex] type is preferable to the @racket[Complex] type for the same reason. Typed Racket can keep @tech[#:doc '(lib "scribblings/reference/reference.scrbl") #:key