Jump to content

Simple Bitwise Question...I hope


mem0ri

Recommended Posts

I've got a situation where...in the one case I'm setting a bitwise value $x:

$x = (2 << $y);

 

And another where I need to instead 'discover' the value of $y if $x is known instead...

 

$y = 2 ???? $x;

 

I could run a while loop....

 

while(($x/2) != 2) $z++;

 

But I'm wondering if someone might know another, more 'efficient' way of working out the equation?  It SEEMS like there must be an inverse relationship with << and >> that would allow you to figure how many bit's a number is shifted...

 

BTW...I'm using only factorial values in this area of the app...so all numbers would come out as 'clean' numbers like 2, 4, 8, 16, 32, etc.

Link to comment
https://forums.phpfreaks.com/topic/89811-simple-bitwise-questioni-hope/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.