Can someone help me with something?
I need to generate the following numbers in a combobox, so I don't have to type them out statically.
8, 16, 24, 32 40, 48, 56, 64 80, 96, 112, 128 144, 160, 192, 224, 256, 320, 512
If you notice there is a pattern, every even square of 8 the increment increases by 8. For instance, the numbers increase by 8 up until it hits 64, which is a perfect square of 8, and then it starts adding 16, it continues this pattern.
Just added information is that this is for the audio bit depth in the new sound editor for LGM 1.8.4
Anyway, I wrote the following for loop.
for (int i = 0; i <= 512; i += 8 * Math.sqrt(i)) { bitOptions.add(Integer.toString(i)); }
However I only need to increment i by the multiplicative of the lowest square root, so if for instance i is 0 or 8, I need the result to be 1, but when it is 64 I need the result to be 2 * 8. Got any ideas?
|