[plt-scheme] Bit manipulation in PLT Scheme

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Mar 16 12:33:41 EST 2006

At Thu, 16 Mar 2006 12:23:32 -0500, Eli Barzilay wrote:
> On Mar 16, Matthew Flatt wrote:
> > At Wed, 15 Mar 2006 19:53:58 +0000, "Paulo J. Matos" wrote:
> > > How can I know when I have a 30 or 62 bit fixnum then?
> > 
> > There's no simple way to tell, currently.
> 
> Wouldn't
> 
>   (eq? (expt 2 35) (expt 2 35))
> 
> work?

This is fragile. MzScheme will compile the above expression to the
constant #t or #f.

This sort of problem is why I'm reluctant to add `fixnum?' to the
language. Right now, I think that "fixnum" is just an implementation
and performance concept, instead of being part of the language.

> And related to that -- it seems that something like a `fixnum?' or
> `most-positive-fixnum' would be useful for bit-manipulation cases and
> foreign interaction...

Foreign interaction is a good idea: using `(lib "foreign.ss")',
`(compiler-sizeof 'long)' will return 4 for a 32-bit platform or 8 for
a 64-bit platform.

Matthew



Posted on the users mailing list.