From ddd503a20346f4358e1aa8c8344e2401d605bbd4 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Thu, 9 Apr 2015 20:44:08 -0700 Subject: [PATCH] Fix type on integer-sqrt/remainder. It doesn't return exact integers when given inexact input. --- .../base-env/base-env-numeric.rkt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt b/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt index c905ed8a..74f546f1 100644 --- a/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt +++ b/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt @@ -3,7 +3,7 @@ (begin (require (for-syntax racket/base racket/syntax syntax/parse) - (only-in (rep type-rep) Type/c?) + (only-in (rep type-rep) Type/c? make-Values) racket/list racket/math racket/flonum racket/extflonum racket/unsafe/ops unstable/sequence racket/match (for-template racket/flonum racket/extflonum racket/fixnum racket/math racket/unsafe/ops racket/base (only-in "../types/numeric-predicates.rkt" index?)) @@ -1721,21 +1721,22 @@ (-Real . -> . N))] ; defined on inexact integers too, but not complex [integer-sqrt/remainder (from-cases - (-Zero . -> . (-values (list -Zero -Zero))) + (-RealZero . -> . (make-Values (list (-result -RealZero -true-filter (-arg-path 0)) + (-result -RealZero -true-filter (-arg-path 0))))) (-One . -> . (-values (list -One -Zero))) (-Byte . -> . (-values (list -Byte -Byte))) (-Index . -> . (-values (list -Index -Index))) (-NonNegFixnum . -> . (-values (list -Index -NonNegFixnum))) + (-NonNegRat . -> . (-values (list -Nat -Nat))) - (map (λ (t) (t . -> . (-values (list t -Int)))) - (list -Nat -NonNegRat - -FlonumPosZero -FlonumNegZero -FlonumZero -NonNegFlonum - -SingleFlonumPosZero -SingleFlonumNegZero -SingleFlonumZero -NonNegSingleFlonum - -InexactRealPosZero -InexactRealNegZero -InexactRealZero -NonNegInexactReal - -RealZero -NonNegReal)) + (map (λ (t) (t . -> . (-values (list t t)))) + (list -NonNegFlonum + -NonNegSingleFlonum + -NonNegInexactReal + -NonNegReal)) (-Rat . -> . (-values (list -ExactNumber -Int))) - (-Real . -> . (-values (list N -Int))))] ; defined on inexact integers too + (-Real . -> . (-values (list N -Real))))] ; defined on inexact integers too [log (cl->* (-NonNegRat . -> . -Real)