Search code examples
numbersieee-754representation

Number of numbers between 2 and 3 in IEEE-754


i am learning IEEE-754 representation of numbers. I know how to convert from binary to IEEE and on vice versa. Now i am trying to figure out how to find out how many numbers in single precision are for instance between 2 and 3. So, the sign will be the same for both. Fraction will be a combination i think and exponent is dependent from a proper number(because of shifts). WHat would be a clever way to do it right ? I would be grateful for any help.


Solution

  • Using a handy online IEEE-754 conversion utility:

    2.0 = 0x40000000
    3.0 = 0x40400000
    

    So:

    0x40400000 - 0x40000000 = 0x400000 = 4194304
    

    Answer: 4 million or so.