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 12b196935..ddc29b0a8 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 @@ -420,6 +420,13 @@ (-> -NonPosInt -Int -NonPosFixnum) (binop -Int -Fixnum)))) + (define fxpopcount-type + (lambda () + (fx-from-cases + (-Nat . -> . -NonNegFixnum) + (-NonNegFixnum . -> . -NonNegFixnum) + (-Int . -> . -Fixnum)))) + ;; A bit of machinery to allow floating point operations to be abstracted over double/extended ;; floating point types without repetition. (define-syntax (define-fl-type-lambda stx) @@ -1946,6 +1953,10 @@ [fxlshift (fxlshift-type)] [fxrshift (fxrshift-type)] +[fxpopcount (fxpopcount-type)] +[fxpopcount16 (fxpopcount-type)] +[fxpopcount32 (fxpopcount-type)] + [fx= (fx=-type)] [fx< (fx<-type)] [fx> (fx>-type)] diff --git a/typed-racket-test/succeed/fixnum.rkt b/typed-racket-test/succeed/fixnum.rkt index e679832ee..fe3c836ce 100644 --- a/typed-racket-test/succeed/fixnum.rkt +++ b/typed-racket-test/succeed/fixnum.rkt @@ -38,3 +38,6 @@ (check equal? (fxmin 3 2) 2) (check equal? (fxmax 3 4) 4) +(check equal? (fxpopcount #x0fffffffffffffff) 60) +(check equal? (fxpopcount32 #xffffffff) 32) +(check equal? (fxpopcount16 #xffff) 16)