@@ -0,0 +1,1256 @@
+/**%0A * Copyright %C2%A9 2014  Mattias Andr%C3%A9e (maandree@member.fsf.org)%0A * %0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A * %0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A * %0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0Apackage algorithms.bits;%0A%0A%0A/**%0A * Power of 2 interger operations%0A */%0Apublic class Powers%0A%7B%0A%C2%A3%3Cfor T in char byte short int long; do%0A    /**%0A     * Compute whether an integer is a power of two,%0A     * note that zero is indeed not a power of two%0A     * %0A     * @param   value  The integer%0A     * @return         Whether the integer is a power of two%0A     */%0A    public static boolean isPowerOf2(%C2%A3%7BT%7D value)%0A    %7B%0A%09return (value & (value - 1)) == 0;%0A%09/* Or alternatively: (value & -value) == value */%0A    %7D%0A%C2%A3%3Edone%0A%7D%0A%0A

add is power of two