Javascript examples for Number Operation:Bit Operation
Find the lowest set bit in int number
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from w ww . j a va 2 s . c o m function filterFirstFoundBit(number) { for (var i = 1; i < 32; i++) { if ((1 << i) & number) { return 1 << i; } } return number; } document.write(filterFirstFoundBit(10)); //01010 }); </script> </head> <body> </body> </html>