public static int flip_bit_at(final int val, final int at_index) {
        assert(at_index >= 24); // we're only flipping bits in least sig byte of val
        final char[] chars = getZeroPaddedBinaryString(val).toCharArray();
        chars[at_index] = chars[at_index] == '1' ? '0' : '1';
        final int i = Integer.parseInt(new String(chars), 2);
        return i;
    }