value range propagation for _bitwise_ OR

"Jérôme M. Berger" jeberger at free.fr
Tue Apr 13 10:48:11 PDT 2010


Steven Schveighoffer wrote:
> using your highbit function, which is very neat BTW
> 
	Thanks, but I can't claim credit for it. It's a classical algorithm
which comes up regularly in programming discussions and newsgroups...

> uint maxor(uint mina, uint maxa, uint minb, uint maxb)
> {
>     return maxa | maxb | ((1 << highbit(((1 << (max(highbit(mina ^
> maxa), highbit(minb ^ maxb)) + 1)) - 1) & maxa & maxb)) - 1);
> }
> 
	Neat!

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100413/617bd24d/attachment.pgp>


More information about the Digitalmars-d mailing list