Strangeplant
08-28-2006, 02:26 PM
Hi - I'm stuck again,
How do I test the various bits [values (0 or 1)] of binary numbers? (I can't find the php method so far.....) For example, I need to know if bit n is true or false, set or not set. (I do know how to move bits and compare binaries, etc., but that does not help me with what I need to do.)
I've decoded Hex into Binary with the function:
function hex2bin($source)
{
$strlen = strlen($source);
for ($i=0;$i<strlen($source);$i=$i+2)
{
$bin .= chr(hexdec(substr ($source, $i,2)));
}
return $bin;
} (Various logic operations will be based on a look-up and test of the retrieved & converted Hex strings. I've used Hex because I can read/edit them with a MySQL database editor)
How do I test the various bits [values (0 or 1)] of binary numbers? (I can't find the php method so far.....) For example, I need to know if bit n is true or false, set or not set. (I do know how to move bits and compare binaries, etc., but that does not help me with what I need to do.)
I've decoded Hex into Binary with the function:
function hex2bin($source)
{
$strlen = strlen($source);
for ($i=0;$i<strlen($source);$i=$i+2)
{
$bin .= chr(hexdec(substr ($source, $i,2)));
}
return $bin;
} (Various logic operations will be based on a look-up and test of the retrieved & converted Hex strings. I've used Hex because I can read/edit them with a MySQL database editor)