I am trying to figure out how many different whole numbers exist in the ieee 754. The number I got was 1778384895 but I couldn\'t find any resource to check myself. Thanks a
I agree with Jester's answer. As a cross-check, and to demonstrate an alternative approach, I wrote, in Java, a brute force scan of all the finite float numbers, counting the ones that are integers. Math.nextUp returns the smallest positive float for either form of zero, so zero only gets counted once.
public class Test {
public static void main(String[] args) {
long count = 0;
for (float f = -Float.MAX_VALUE; f <= Float.MAX_VALUE; f = Math.nextUp(f)) {
if (Math.rint(f) == f) {
count++;
}
}
System.out.println(count);
}
}
It output 1778384895