BitArray (compacting 32 bool values into one integer)
public void set(int index, boolean value) {
    int actualIndex = (int)Math.floor(index / 32f);
    int elementValue = elements[actualIndex] &amp; ~(0x01 &lt;&lt; (index % 32));

    if (value) {
        elementValue = elementValue | (0x01 &lt;&lt; (index % 32));
    }

    elements[actualIndex] = elementValue;
}


You can avoid a bit of recalculation here by caching the shift value. Also, switch to long to increase the range of values the user can enter

public void set(long index, boolean value) {
    final long actualIndex = (long)Math.floor(index / 32f);
    final long mask = 0x01 &lt;&lt; (index % 32);
    long elementValue = elements[actualIndex] &amp; ~mask;

    if (value) {
        elementValue |= mask;
    }

    elements[actualIndex] = elementValue;
}