PHP code example of vinicciusguedes / laravel-bitwise
1. Go to this page and download the library: Download vinicciusguedes/laravel-bitwise library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vinicciusguedes / laravel-bitwise example snippets
$currentValue = 5; // 0101 em binário
$bitToAdd = 2; // 0010 em binário
$newValue = Bitwise::addBit($currentValue, $bitToAdd); // 7 (0111 em binário)
$currentValue = 5; // 0101 em binário
$bitToAdd = [2, 4];
$newValue = Bitwise::addBits($currentValue, $bitToAdd); // 7 (0111 em binário)
$currentValue = 7; // 0111 em binário
$bitToRemove = 2; // 0010 em binário
$newValue = Bitwise::removeBit($currentValue, $bitToRemove); // 5 (0101 em binário)
$currentValue = 15; // 1111 em binário
$bitToRemove = [1, 4];
$newValue = Bitwise::removeBits($currentValue, $bitToRemove); // 10 (1010 em binário)
$currentValue = 5; // 0101 em binário
$bitToCheck = 4; // 0100 em binário
$isActive = Bitwise::hasBit($currentValue, $bitToCheck); // true