floating-pointbinarynumericdate-arithmeticinteger-arithmetic

What is the minimum odd number representable in a 32-bit float, written in both decimal and binary?


What is the minimum odd number that can be accurately represented with a float? Assume that the float is represented with 32 bits where: 1 bit is used for the sign, 8 bits for the exponent and 23 bits for the fraction. The answer must be written in both the decimal base and the bits of the float.

I'm not sure whether they're asking for the the smallest as for the "closest to zero" therefore the answer is maybe 1, or are they meaning the smallest as for "closest to minus infinty"?


Solution

  • From IEEE 754 standard: binary32:

    • Sign bit: 1 bit
    • ...
    • Significand precision: 24 bits (23 explicitly stored)

    Whole numbers up to this value (up to representable by 24 bit whole unsigned numbers) are stored in float 32 exactly. So, minimum exact odd number is:

    - 0b 1111 1111 1111 1111 1111 1111
    

    or - 16 777 215 decimal