Here's a fast 100% precise solution:

==============================8<------------------------------
uint32_t maxOr (uint32_t minA, uint32_t minB,
                uint32_t maxA, uint32_t maxB)
{
   assert (minA <= maxA);
   assert (minB <= maxB);

   if (maxA == 0) return maxB;
   if (maxB == 0) return maxA;

   uint32_t a = maxA ^ minA;
   if (a != 0) {
      a = ((1 << (highbit (a)+1)) - 1) & maxA & maxB;
      if (a != 0)
         a = (1 << highbit (a)) - 1;
   }

   uint32_t b = maxB ^ minB;
   if (b != 0) {
      b = ((1 << (highbit (b)+1)) - 1) & maxA & maxB;
      if (b != 0)
         b = (1 << highbit (b)) - 1;
   }

   return maxA|maxB|a|b;
}
------------------------------>8==============================

                Jerome
-- 
mailto:jeber...@free.fr
http://jeberger.free.fr
Jabber: jeber...@jabber.fr

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to