Jump to content

Weird Bitwise Bug


gmoeck

Recommended Posts

In doing user permissions, I'm having a weird bug with a bitwise and. The values are being stored correctly, yet when the 'and' is done the value that returns varies by which server the command is done on. Example:

 

$user["permissions"] = 54975580511 //0x7FFFFFDF47

$CLIENT_VIEW = 4294967296 // 0x10000000

 

$user["permissions"] & $CLIENT_VIEW => 0 on one of our servers.

 

Any suggestions?

 

Link to comment
Share on other sites

I would expect the answer to be same as $CLIENT_VIEW although my server gives 0

 

<?php
echo base_convert('7FFFFFDF47', 16,2);
echo '<br>';
echo '000000' . base_convert('4294967296', 10,2);


?>

-->

111111111111111111111111101111101000111
000000100000000000000000000000000000000 

That is exactly what I would expect as well, yet one of our servers gives 0, just like yours. Any idea what might yield this result? Why would the server give 0, and not the value of $CLIENT_VIEW?

 

In binary, I would expect 000000100000000000000000000000000000000, which should be non-zero.

Link to comment
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.