[plt-scheme] Fixnum Conversion

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Apr 11 09:52:08 EDT 2009

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!

Posted on the users mailing list.