Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.