3 ms·
If you do this, int count = 1; int limit = Float.floatToIntBits(1.0f); for (int intBits = Float.floatToIntBits(0.0f); intBits <= limit;
by marginalia_nu 4y ago
If you do this,
int count = 1;
int limit = Float.floatToIntBits(1.0f);
for (int intBits = Float.floatToIntBits(0.0f); intBits <= limit; intBits++) {
count++;
}
it will start out with the same performance as your previous one, and then after a few tries the JVM will optimize it into a constant.
1065353218, 0.91
1065353218, 0.69
1065353218, 0.00
1065353218, 0.64
1065353218, 0.64
1065353218, 0.63
1065353218, 0.66
1065353218, 0.63
1065353218, 0.63
1065353218, 0.00
1065353218, 0.00
1065353218, 0.00
...
1065353218, 0.00
Process finished with exit code 0