floating point representations##
exponent == 7 bits ,mantissa == 8 bits
- 2044 = 0 1001001 11111111
- 2045.5 = 0 1001001 11111111
why is this happening?? what is the error? Is anything wrong with the conversion?
exponent == 7 bits ,mantissa == 8 bits
why is this happening?? what is the error? Is anything wrong with the conversion?
Not sure what format this, as IEEE 16-bit float has 5 bit exponent and 10 bit mantissa (with hidden 1 bit, so effective 11 bits).
However, your format has more exponent bits and fewer mantissa bits than the standard one. With only 8 bits of mantissa, only 256 different values can be differentiated at the same exponent value. While that is "ok" at lower exponent values (all integers can be represented, and further some fractions), as soon as the exponent value is larger than 29, then 256 is simply not enough bits to represent all the possible integers, let alone fractions.
2044 requires 11 bits and 2045.5 requires 12 bits to represent exactly.
Your format may or may not utilize the hidden leading 1 common with IEEE formats. If not then the numbers will be forced to round to 8 bits, and if so, then as if to 9 bits. Either way, these two numbers cannot be differentiated with such limited mantissa.
These numbers require an exponent of around 211, which would require 11 bits to represent all possible integers (more for fractions).