News for hackers. Stuff that matters.
Re:How many floating-point numbers are in the interval [0,1]... by enriquto on Saturday April 15, 2023 @11:31AM (#35581510)
In standard C you have nextafterf(3) that gives the next float and allows to traverse them starting from 0:

    #include <math.h>   // nextafterf
    #include <stdio.h>  // printf

    int main()
    {
             long n = 1;
             float f = 0;
             while (f <= 1)
             {
                      f = nextafterf(f, 2);
                      n = n + 1;
             }
             printf("%ld\n", n);
             return 0;
    }

There are no comments on this comment yet.