0
$\begingroup$

If I have a 32-bit representation of a floating-point where 1 bit is the sign, 8 bits are the exponent, and 23 bits make up the mantissa. The exponent notation is Excess-127.

32=1+8+23

And, where the "1." of the mantissa is implied and not stored in the binary sequence.

It makes sense to me to calculate the largest, possible, positive floating-point using this formula:

(implicit "1." value) + (largest possible bit sequence) × (largest possible exponent)

... which in this case is:

(1) + ( { 2^(23) - 1 } x {2^128} )

The textbook I'm studying from uses this formula:

+ { 1 - 2^(-24) } x 2^(128)

The only part; in this formula; that makes sense to me, is 2^(128). I don't understand why they are using 2^(-24). I don't understand why they are subtracting 2^(-24) from 1 either.

Is the formula correct? And if so, how does it work? If anyone could point me to resources that explain this I would really be grateful.

$\endgroup$
  • $\begingroup$ You would also need to specify the format of the exponent. Here it seems to be signed int8, while the IEEE format with the same bit distribution uses an unsigned int8 format that is then shifted by a bias of 127 (the corresponding bias for the double format is accordingly 1023). $\endgroup$ – LutzL Feb 24 '17 at 16:55
  • $\begingroup$ Sorry, I thought with 8 bits for the exponent representation, it was obvious that it the notation was Excess-127. I'm still learning, sorry. $\endgroup$ – einScotchFitch Feb 24 '17 at 17:08
  • $\begingroup$ Then the book is either wrong or reserves the highest exponent for non-numerical values/exceptions, as that formula only works if the highest useful exponent is $127$. $\endgroup$ – LutzL Feb 24 '17 at 18:34
  • $\begingroup$ @Lutzl Please look at this math.stackexchange.com/questions/2158495/excess-notation-sys‌​tem is the answer there correct? If not why not. Please. $\endgroup$ – einScotchFitch Feb 24 '17 at 19:05
  • $\begingroup$ Yes, it is correct. That way the IEEE754 number formats are constructed. But it is not clear, despite the obvious similarities, if the format in your task is the IEEE754 32 bit floating point format. $\endgroup$ – LutzL Feb 24 '17 at 21:31
-1
$\begingroup$

Your formula is slightly off. Your expression (2^23)-1 represents the 'all 1s' of the maximum mantissa - but you have forgotten that this is a fraction. To make it a fraction you must scale it by a factor of 2^-23 before adding 1. If you work out the math, you will see that then it will be equivalent to the textbook formula.

I also believe you and the textbook are both wrong about the exponent - it should be at most 2^127 (assuming the 8-bit value is signed twos-complement, which has the value range [-128..127]).

$\endgroup$
  • $\begingroup$ No, the book is correct as $(1.1111…1)_2=2-2^{-23}$ and $2^{127}·(2-2^{-23})=2^{128}·(1-2^{-24})$. Note that in the IEEE format, the highest and lowest exponents are reserved for infinity and NAN. $\endgroup$ – LutzL Feb 24 '17 at 16:51
  • $\begingroup$ @PMar But the exponent is Excess-127 so it's unsigned with range -127 to 128. Right? $\endgroup$ – einScotchFitch Feb 24 '17 at 17:01
  • $\begingroup$ @PMar Also what do you mean scale it by 2^-23? I assumed the computer stores the mantissa binary string and adds "1." to it, because it wouldn't actually be able to represent a "."? I don't understand what you mean by scaling or why you use the exponent -23? $\endgroup$ – einScotchFitch Feb 24 '17 at 17:29
  • $\begingroup$ math.stackexchange.com/questions/2158495/excess-notation-system here I explain how I thought Excess notation worked... but now I am doubting it. $\endgroup$ – einScotchFitch Feb 24 '17 at 17:40
  • $\begingroup$ @einScottFitch Neither formula is referring to storage of bits in a computer representation, aka string catenation; they are both arithmetical expressions for the value of the largest representable value. The textbook expression correctly represents the mantissa value by subtracting a fractional magnitude. The submitter's expression's ' (2^23) - 1' is an integer, approximately 8 million; hence in order to make the mantissa a fraction it needs to be scaled down. INCIDENTALLY: I just noticed that the submitter's expression mis-brackets the mantissa, i.e the '{}' are misplaced. $\endgroup$ – PMar Feb 24 '17 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.