Exemplo n.º 1
0
function strbin2ulong($value)
{
    if (!is_array($value)) {
        $value = str2arr($value);
    }
    /* make sure value is a value */
    $ulong = pack("L", binstr2int($value));
    return $ulong;
}
Exemplo n.º 2
0
function ivcs_transform_to($hex)
{
    global $ivcs;
    $boolArr = hexString_2_booleanArray($hex);
    // Convert Hex input to an array of 1's and 0's
    $boolArr = array_merge($boolArr, rfc2289_checksum($boolArr));
    // append checksum to form 66 bit array
    for ($i = 0; $i < 6; $i++) {
        $arrSlice = array_slice($boolArr, $i * 11, 11);
        // extract the 11 bits that we want
        $index = binstr2int(implode($arrSlice));
        // create an integer index from the bits
        $word[$i] = $ivcs[$index];
        // look up the code word
    }
    return $word;
}
Exemplo n.º 3
0
 function testValid32DigitBinString()
 {
     $parameter = "111101100010101110011010110001101";
     $decval = 16133018;
     $retval = binstr2int($parameter);
     $this->assertTrue($decval == $retval, "bin string {$parameter} should convert to {$decval}, converted to {$retval}");
 }