PHPDaemon\Utils\Crypt::getMinimalBitMask PHP Method

getMinimalBitMask() protected static method

Returns the smallest bit mask of all 1s such that ($toRepresent & mask) = $toRepresent
protected static getMinimalBitMask ( integer $toRepresent ) : integer
$toRepresent integer must be an integer greater than or equal to 1
return integer
    protected static function getMinimalBitMask($toRepresent)
    {
        if ($toRepresent < 1) {
            return false;
        }
        $mask = 0x1;
        while ($mask < $toRepresent) {
            $mask = $mask << 1 | 1;
        }
        return $mask;
    }