Skip to content
Advertisement

Tag: bitwise-operators

Get bitwise and of all elements of an array in php

if i have and array like and i want to do a bitwise add operator for all elements like What will be the logic and how to do it ? Answer This can be achieved with the following one-liner: It uses array_reduce to ‘loop’ over the array, reducing it to one value. The callback function performs the bitwise operation.

Python bitshifting vs PHP bitshifting

I have a code in python which uses right bit shift and it returns the correct value but the same way I tried to shift right in PHP, it returns 0. Python code: PHP code: I have a very little experience in maths functions, would be great if someone can help. Answer This operator >> is working on an integer

Advertisement