FYI - UDP guarantees delivery of uncorrupted, complete datagrams, or no
delivery at all.  The protocol performs a CRC on the payload, UDP header and
IP header.  So, if the data is corrupted during delivery, or if the datagram
is fragmented into small packets that are not all delivered, the whole UDP
datagram is discarded.  I believe that you can turn off UDP's CRC check with
a socket option on some stacks, but LAN link-layer firmware usually performs
CRC checks and discards corrupted packets as well.

Cheers,
        Nat.

----- Original Message -----
From: "Hugh Sasse Staff Elec Eng" <hgs / dmu.ac.uk>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Friday, July 27, 2001 3:39 PM
Subject: [ruby-talk:18634] Most Sig. NonZero bit, efficiently?


> I see that integer types (Bignum and Co.) support [] to get the kth bit
out.
> They don't seem to have each (which is interesting) so what is the
> most effective way to get the most significant non-zero bit in a bignum?
>
> Obviously log to base 2 is heavy machinary for this task, and the only
> other way I can see to do this is:
>
> top = my_number.size * 8
> while ((my_number[top] == 0) && (top > 0) ) { top -= 1 }
>
> but this seems a little primitive.
>
> Why do I need this stuff?  I'm trying to create Cyclic Redundancy Check
> information for marshalled data I'm sending over UDP.  AFAIK UDP
guarantees
> nothing -- arrival, ordering, or intact data may, or may not happen.
> The CRC algorithm relies on a bitwise long-division-like process, but
using
> XOR instead of divide, so hence the need to align MSBs frequently.
>
>         Hugh
>
>
>