Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Bit-Manipulation/BinaryCountSetBits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
author: vivek9patel
license: GPL-3.0 or later

This script will find number of 1's
in binary representain of given number

*/

function BinaryCountSetBits (a) {
'use strict'
// convert number into binary representation and return number of set bits in binary representaion
return a.toString(2).split('1').length - 1
}

// Run `binary_and` Function to find the binary and operation
console.log(BinaryCountSetBits(251))