value range propagation for _bitwise_ OR

"Jérôme M. Berger" jeberger at free.fr
Sun Apr 11 14:28:57 PDT 2010


Ali Çehreli wrote:
> � wrote:
> 
>> The idea is to build a value that is  between minA and maxA and will
>> set as many bits as possible when or'ed with maxB:
> 
> The assumption that maxB would be the value that produces the maximum
> a|b is not correct. A lower valued b may fill more gaps in the bit
> representation of what is calculated from min_a and max_a.
> 
> Your function failed for me with the following values:
> 
>            min_a 00000000000000000000000011001000 000000c8        200
>            max_a 00000000000000000000001100001111 0000030f        783
>            min_b 00000000000000000000000001000101 00000045         69
>            max_b 00000000000000000000001001100001 00000261        609
>       calculated 00000000000000000000001001100101 00000265        613
> WRONG! empirical 00000000000000000000001111111111 000003ff       1023
>        emp_max_a 00000000000000000000000110011110 0000019e        414
>        emp_max_b 00000000000000000000001001100001 00000261        609
> 
> Please see my test code elsewhere in the same thread: :)
> 
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=108851
> 
	The "calculated" value above obviously was not computed with my
function! Since the return value from my function includes maxA and
maxB, at least all bits that are set in either of those should be
set in the output.

	I've run my code with those input and the result is 3ff as
expected... (See attached source file).

		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: maxor.cc
Type: text/x-c++src
Size: 1410 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100411/ad9e2de7/attachment.cc>
-------------- 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/20100411/ad9e2de7/attachment.pgp>


More information about the Digitalmars-d mailing list