-- 6gJ3Kf8/NaVAkBCfZej Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > Related question: The JavaScript version uses a shift right, zero fill > operation. Ruby seems to only offer signed shift-right. Is this the > case? Is there a Ruby version of shift right, zero fill someplace? AFAIK Ruby only supports arithmetic, not logical right shift. But logical right shift is quite easy to implement. Just shift the number of bits and then mask the same number of the "front" bits. For example, if you have a 32-Bit long number and want to shift one bit & fill with zero you could do i = (i >> 1) & 0x7FFFFFFF irb(main):001:0> i = -3 => -3 irb(main):002:0> 31.downto(0) do |n| print i[n] end 11111111111111111111111111111101=> 31 irb(main):003:0> i = (i >> 1) & 0x7FFFFFFF => 2147483646 irb(main):004:0> 31.downto(0) do |n| print i[n] end 01111111111111111111111111111110=> 31 irb(main):005:0> regards /max -- 6gJ3Kf8/NaVAkBCfZej Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iQCVAwUAQqb7/7C1SnkHJ6uKAQKPhwQAzeksphosz3fXG8N0hnRXhvmyUL+8VWsZ p2LtiUvI9QT4whYVsq2EujsvABNulMdYE90SFC9fhNNkkxGtR9cTP8RdrW2NJTub Y0nmtYm3KBTsQK52V3he9rAKZX8xnYLCcwlYwYK60g1XVhCcXxgHdzThZMnh1Eph DiMLOnOIm38 Wq -----END PGP SIGNATURE----- -- 6gJ3Kf8/NaVAkBCfZej--