Welcome to the Monastery | |
PerlMonks |
comparing bit vectorsby citromatik (Curate) |
on Jun 11, 2009 at 09:48 UTC ( [id://770578]=perlquestion: print w/replies, xml ) | Need Help?? |
citromatik has asked for the wisdom of the Perl Monks concerning the following question: Hi all In a recent post, someone asked how to find if two numeric ranges overlap. I couldn't resist to try a solution based on bit vectors. That is, create 2 bit vectors with the bits inside the range set to "1", and see if the & operation on them give something different to a vector of '0's. Something like:
This works as expected:
but I find a bit tricky to have to build the '0' vector for comparisons and the fact that the bit vectors 000 and 0000000000000000 are not equals Is there a better way to see if a bit vector has all its bits set to '0'? Thanks in advance citromatik
Back to
Seekers of Perl Wisdom
|
|