[racket] Best typed/racket representation for bitfield of width 125?

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Thu Sep 4 15:35:57 EDT 2014

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

Posted on the users mailing list.