Toggle the last m bits | function to toggle the last m bits ; calculating a number ' num ' having ' m ' bits and all are set . ; toggle the last m bits and return the number ; Driver code
function toggleLastMBits ( n , m ) { var num = ( 1 << m ) - 1 ; return ( n ^ num ) ; } var n = 107 ; var m = 4 ; document . write ( toggleLastMBits ( n , m ) ) ;