trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
185.25k stars 29.89k forks source link

Better `isPowerOfTwo` algos and files #892

Open Rudxain opened 2 years ago

Rudxain commented 2 years ago

Closes #889.

The bitwise approach isn't mathematically correct, because it only works for 32bit ints, therefore it should be exclusive to the math/bits directory.

I also added info about the supported input args for both the trial division approach and the bitwise approach

Rudxain commented 2 years ago

Now the non-bitwise fn supports BigInts