Skip to content

Commit b25f195

Browse files
authored
Merge pull request TheAlgorithms#316 from vivek9patel/master
added bit_manipulation folder & binary_count_setbits.js
2 parents a89859f + 89f5def commit b25f195

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
author: vivek9patel
3+
license: GPL-3.0 or later
4+
5+
This script will find number of 1's
6+
in binary representain of given number
7+
8+
*/
9+
10+
function BinaryCountSetBits (a) {
11+
'use strict'
12+
// convert number into binary representation and return number of set bits in binary representaion
13+
return a.toString(2).split('1').length - 1
14+
}
15+
16+
// Run `binary_and` Function to find the binary and operation
17+
console.log(BinaryCountSetBits(251))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy