how did you get this value? Is there any mathematical basis?
how did you get this value? Is there any mathematical basis?
if you know why the exponential offset of a 32-bit floating-point number is 127, you can know why the exponential offset of a 64-bit floating-point number is 1023.
in 32-bit floating-point numbers, the exponential bit has 8 bits, and the number it can represent is from 0 to the eighth power of 2, that is, 256. But there are positive and negative exponents, so we need to take the number 256from the middle Slash, half for positive and half for negative, so it's-128to + 128. Oh, no, I forgot that there is a zero in the middle, so it can only represent 256 numbers from-128 to 127. So how do you record negative numbers? One way is to put the high position 1, so that as long as we see that the high position is 1, we know that it is negative. The so-called high position 1 means to split so many numbers from 0 to 255 in half, from 0 to 127 for positive numbers and from 128 to 255 for negative numbers. But this raises a question: when you compare two numbers, such as 130 and 30, who is bigger? The machine will think 130 is bigger, but in fact 130 is a negative number. It should be smaller than 30. So in order to solve this problem, people invented another way: simply add all the numbers to it, so that-128 plus 128 becomes 0, and 127 plus 128 becomes 255, so that the size of the negative number is larger than that of the positive number.
but what should I do if I get the original number? That's easy. You just subtract the index by 128 and you get the original number, don't you? For example, if you read 0, minus 128, you get the negative exponent-128, read 255, minus 128, and you get 127.
then why is the exponential offset 127 instead of 128? Because for special purposes, people are not allowed to use the numbers 0 and 255 to represent the index, if there are two less numbers, naturally they have to use 127.
similarly, 64-bit floating-point numbers have as many as 11 exponential bits, and the 11th power of 2 is 2048. Split half to offset, isn't it 1024? By the same token, the numbers 0 and 2048 are removed, so 1023 is used as the offset.
80-bit extended double precision, one truth.