Compute modulus division by a power | This function will return n % d . d must be one of : 1 , 2 , 4 , 8 , 16 , 32 , ... ; Driver Code ; d must be a power of 2
< ? php function getModulo ( $ n , $ d ) { return ( $ n & ( $ d - 1 ) ) ; } $ n = 6 ; $ d = 4 ; echo $ n , " ▁ moduo " , " ▁ " , $ d , " ▁ is ▁ " , " ▁ " , getModulo ( $ n , $ d ) ; ? >