Re: [dev] [sbase] Patch to make md5 and sha1 more similar

From: Szabolcs Nagy <nsz_AT_port70.net>
Date: Mon, 15 Jul 2013 17:14:45 +0200

* Jens Nyberg <jens.nyberg_AT_gmail.com> [2013-07-15 16:51:29 +0200]:
> Hehe and I almost thought about changing to (x & 0x3f) instead of (x % 64)
> but decided to skip that one =)
>

note that
x&63 and x%64
x>>6 and x/64
x<<6 and x*64
are not the same when x might be negative

(if x is negative then x&63 depends on the signed int representation,
but guaranteed to be in [0,63] while x%64 is in [-63,0], x>>6 is
implementation defined and usually very different from x/64 and
x<<6 is undefined while x*64 is only undefined when it overflows)

so the compiler (and you) can only interchange these freely
if it can be proven that x cannot be negative
(eg because its type is unsigned)
Received on Mon Jul 15 2013 - 17:14:45 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 15 2013 - 17:24:06 CEST