[plt-scheme] Fixnum Conversion

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Sat Apr 11 16:55:08 EDT 2009

The packed-binary collection on PLaneT can convert between various binary
formats and byte strings. It's patterned after a similar capability in
Python.

On Sat, Apr 11, 2009 at 7:52 AM, Eli Barzilay <eli at barzilay.org> wrote:

> On Apr 11, Erich Rast wrote:
> > Hi all,
> >
> > I'm a bit confused about numbers. A fixnum can hold numbers that fit
> > into 31 or 63 bits depending on whether the machine is 32 bit or 64
> > bit, right?
> >
> > How do I convert a positive integer number in the range from
> > 0...4294967295 (inclusive) on any machine to a little-endian encoded 4-
> > element bytes string?
>
> You can use (integer->integer-bytes 4294967295 4 #f #f) -- with #f for
> the `signed?' flag, since otherwise it doesn't fit into 4 bytes.
>
> --
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                  http://www.barzilay.org/                 Maze is Life!
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090411/bab6e210/attachment.html>

Posted on the users mailing list.