Thank you so much for your very quick answer.<div>It seems that the conversion to and from bytes are what I was looking for.</div><div>With that, it is quite easy to do all the manipulations I want.</div><div><br></div><div>
Best,</div><div><br></div><div>Nicolas.</div><div><br></div><div>
<br><div class="gmail_quote">On Sat, Oct 8, 2011 at 6:57 PM, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu" target="_blank">mflatt@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>At Sat, 8 Oct 2011 17:41:35 +0100, "<a href="mailto:nicolas.oury@gmail.com" target="_blank">nicolas.oury@gmail.com</a>" wrote:<br>
> I am trying to write a small implementation of Protocol Buffers (<br>
> <a href="http://code.google.com/p/protobuf/" target="_blank">http://code.google.com/p/protobuf/</a> ) and I have difficulties<br>
> with bit manipulations, especially to transform a negative integer into a<br>
> series of bytes and back.<br>
><br>
> I can not find an implementation of a non-arithmetic shift for fixnums, and<br>
> a way to specify which size of fixnum to construct.<br>
<br>
</div>There aren't different sizes of fixnums. When you want to convert an<br>
exact integer to bytes, then `integer->integer-bytes' lets you specify<br>
the size.<br>
<br>
There also isn't a logical shift operator, if I understand what you're<br>
after. If you work with positive integers, then `arithmetic-shift'<br>
(plus `bitwise-and'?) behaves like a logical shift. If you want<br>
logical-shift effects for finite 2's complement representations, then<br>
you probably don't really want to work on fixnum representations, which<br>
are 63 or 31 bits, but instead some power of 2 via bitwise operations<br>
like `bitwise-ior', `bitwise-and', and arithmetic shifts of negative<br>
numbers. Note also that `integer-bytes->integer' lets you say whether<br>
to interpret a set of bytes as unsigned or as 2's complement.<br>
<div><br>
> I can't also find an easy way to get the byte representation of flonums.<br>
<br>
</div>`real->floating-point-bytes'<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Sent from an IBM Model M, 15 August 1989.<br>
</div>