Checking if an Integer is an Exact Binary Power

Nordlöw via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 23 06:04:00 PDT 2016


Wanted: CT-trait and run-time predicate for checking whether its 
single integer parameter is an exact power of two.

I guess

https://dlang.org/phobos/std_math.html#.truncPow2

or

https://dlang.org/phobos/std_math.html#.nextPow2

could be reused, but I bet there's a more efficient way of 
checking this.


More information about the Digitalmars-d mailing list