If you type check the file on a 64-bit system like yours, but then ran it on a 32-bit system, the fixnum range would change, making that number into a bignum.
Sam On Sep 6, 2014 8:37 AM, "John Clements" <[email protected]> wrote: > Is this a bug, or just a known limitation of typed racket? It looks like a > fixnum can be up to 2^61, but the type checker for integer literals doesn't > like them. This program: > > #lang typed/racket > > (require racket/fixnum) > > (define (ensure-fixnum i) > (cond [(fixnum? i) i] > [else (error 'ensure-fixnum)])) > > (fixnum? 281474976710656) ;; -> #t > (: i Fixnum) > (define i (ensure-fixnum 281474976710656)) > > works fine, but requires the ensure-fixnum, because the type checker does > not believe that the literal 281474976710656 lives in fixnum. > > You can also see this at the top level, using (:print-type 281474976710656) > > Is this a bug, or is this just a known compromise to simplify the > type-checker's portability and numeric tower? > > John > > > > > On Thu, Sep 4, 2014 at 12:35 PM, Vincent St-Amour <[email protected]> > wrote: > >> Would an fxvector of length 5 (to account for the tag bits) work? >> >> If all you're doing is bitwise ops and comparisons, it should be easy to >> convince TR that you're staying within fixnum range. >> >> Vincent >> >> >> >> >> At Thu, 4 Sep 2014 10:45:48 -0700, >> John Clements wrote: >> > >> > [1 <multipart/alternative (7bit)>] >> > [1.1 <text/plain; UTF-8 (quoted-printable)>] >> > I want to represent a bitfield of 125 bits, using typed racket. I’ll be >> > combining them using bitwise operations, and checking for zero-ness. I >> > think that’s about it. >> > >> > I could just use type Integer, but it seems like that would impose >> > additional checking, since the type system doesn’t know the size. In >> > untyped racket I used a vector of four integers in the range 0-2^32, but >> > those don’t fit in typed Racket’s “Fixnum” because it uses a signed >> > representation (and indeed, untyped racket may have been falling prey to >> > the same problem. Perhaps I should break it up into four integers in the >> > range 0-2^31? That seems weird, but maybe that’s my best choice? Or… I >> > could use a byte string. >> > >> > Apologies if I’m missing something in the docs, here; I’ve spent a few >> > minutes searching, without turning anything up. >> > >> > Thanks for any advice, >> > >> > John >> > [1.2 <text/html; UTF-8 (quoted-printable)>] >> > >> > [2 <text/plain; us-ascii (7bit)>] >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > >
____________________ Racket Users list: http://lists.racket-lang.org/users

