3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Get bit in specified position from right (LSB position = 0) function getBIT($number, $position) { return ($number >> $position) & 1;} // Set bit in specified position from right (LSB position = 0) function setBIT($number, $position, $value) { if(getBIT($number, $position)){ if(!$value) { $number -= pow(2, $position); if($color == "r"){ $setBITcountR++; //echo "set BITr "; } if($color == "g"){ $setBITcountG++; //echo "set BITg "; } if($color == "b"){ $setBITcountB++; //echo "set BITb "; } } } else { if($value){ $number += pow(2, $position); if($color == "r"){ $setBITcountR++; //echo "set BITr "; } if($color == "g"){ $setBITcountG++; //echo "set BITg "; } if($color == "b"){ $setBITcountB++; //echo "set BITb "; } } } return $number; } echo decbin(setBIT(0b01101001, 3, 0));
based on KkHci
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.21.3, 7.1.0 - 7.3.0beta1
Notice: Undefined variable: color in /in/HfVXV on line 10 Notice: Undefined variable: color in /in/HfVXV on line 14 Notice: Undefined variable: color in /in/HfVXV on line 18 1100001
Output for hhvm-3.22.0
Notice: Undefined variable: color in /in/HfVXV on line -1 Notice: Undefined variable: color in /in/HfVXV on line -1 Notice: Undefined variable: color in /in/HfVXV on line -1 1100001