I am trying to understand how to represent the RGB9E5 format as shown for:
Note that the conversion to a value is given in both of the above as value = mantissa x 2^(exponent - bias - bits_in_mantissa)
For this format, bias = 15 and bits_in_mantissa = 9, and there is no implicit 1 or sign bit.
The data format spec (section 10.4, non-standard float formats) explains how to encode custom formats, and it gives an example of RGB9E5 as well (table 98), but I think I'm missing how that follows.
sampleUpper is supposed to be the mantissa value that represents 1 for exponent (after bias) 0.
sampleLower is supposed to be the mantissa value that represents 0 for exponent (after bias) 0.
For RGB9E5, substituting 0 for exponent - bias, we are left with value = mantissa x 2^(0 - 9).
To represent the value 1, mantissa should then be 512 because 1 = 512 x 2^-9.
To represent the value 0, mantissa should then be 0 because 0 = 0 x 2^-9.
However, in Table 98 (the example for RGB9E5) sampleUpper is set to 256, not 512.
(As expected though, sampleLower = 0, bitLength = 9 and bias (sampleUpper for the exponent sample) = 15).
I wonder if Table 98 contains a mistake, or if I am missing something somewhere.
PS: if 512 is indeed the correct value, then that runs afoul of the "implicit one detection", because 512 is one larger than the representable mantissa value. Moreover, to actually represent the value 1 in RGB9E5, I believe you need to use exponent-after-bias 1 (or higher) or you run out of mantissa bits.
PS2: And by extension, there is no single representation of 1 in RGB9E5 either, because I can arbitrarily bump the exponent by one and shift the mantissa by one, and it's still a value of 1. Is there a specific "representation of 1" that should be used?
I am trying to understand how to represent the RGB9E5 format as shown for:
Note that the conversion to a value is given in both of the above as
value = mantissa x 2^(exponent - bias - bits_in_mantissa)For this format, bias = 15 and bits_in_mantissa = 9, and there is no implicit 1 or sign bit.
The data format spec (section 10.4, non-standard float formats) explains how to encode custom formats, and it gives an example of RGB9E5 as well (table 98), but I think I'm missing how that follows.
sampleUpperis supposed to be the mantissa value that represents 1 for exponent (after bias) 0.sampleLoweris supposed to be the mantissa value that represents 0 for exponent (after bias) 0.For RGB9E5, substituting
0forexponent - bias, we are left withvalue = mantissa x 2^(0 - 9).To represent the value 1, mantissa should then be
512because1 = 512 x 2^-9.To represent the value 0, mantissa should then be
0because0 = 0 x 2^-9.However, in Table 98 (the example for RGB9E5)
sampleUpperis set to 256, not 512.(As expected though, sampleLower = 0, bitLength = 9 and bias (sampleUpper for the exponent sample) = 15).
I wonder if Table 98 contains a mistake, or if I am missing something somewhere.
PS: if 512 is indeed the correct value, then that runs afoul of the "implicit one detection", because 512 is one larger than the representable mantissa value. Moreover, to actually represent the value 1 in RGB9E5, I believe you need to use exponent-after-bias 1 (or higher) or you run out of mantissa bits.
PS2: And by extension, there is no single representation of 1 in RGB9E5 either, because I can arbitrarily bump the exponent by one and shift the mantissa by one, and it's still a value of 1. Is there a specific "representation of 1" that should be used?