[plt-scheme] Bit manipulation in PLT Scheme

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Fri Mar 10 18:33:59 EST 2006

On 10/03/06, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
> > Thanks a lot for the extensive reply. I'll probably go with doing the
> > low-level arithmetic in C and use libffi to use it in PLT Scheme.
>
> Hi Paulo,
>
> If it helps, you may want to also look at the implementation of mzlib's
> md5 module: there's an implementation of 32-bit word vectors in there that
> might be useful for you.  It does the trick of using two 16-bit fixnums to
> avoid bignum issues.  (Perhaps all those bit-operations should be
> refactored out into a separate mzlib module?)
>

Hi Danny,

Thanks for the reference, I took a 'flash' look  through the source
code of md5.ss and I was expecting it to implement in someway the
32bit word vectors using low-level access to C but it doesn't seem so.
Instead it seems to be using numbers < 655...
(define-syntax word
  (syntax-rules ()
    [(word c)
     (cons (quotient c 65536) (remainder c 65536))]))

My doubt is, isn't any number represented in MzScheme interpreted as a
big num be it either 1, 2 or 324234928340928343123? Or MzScheme is
able internally to represent  30000 inside an int since it checks
there is no need for a bignum?


>     http://ja.soegaard.net/planet/html/collects/mzlib/md5.ss
>
>


--
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group


Posted on the users mailing list.