Unset least significant K bits of a given number | Function to return the value after unsetting K LSBs ; Create a mask ; Bitwise AND operation with the number and the mask ; Given N and K ; Function Call
function clearLastBit ( N , K ) { var mask = ( - 1 << K + 1 ) ; return N = N & mask ; } var N = 730 , K = 3 ; document . write ( clearLastBit ( N , K ) ) ;