floating point - Increase a double to the next closest value? -


This is not a question for the real life project; I'm only curious.

We can increase a int by using the pay scale operator ( i ++ ). You can define this operation as:
This increases the variable with the value of i . Which is only 1 in this case.

But I was thinking of defining the number of double values ​​available in a specific category according to the IEEE 754-2008 system. I can set the graph that shows these amounts in some articles and see how it is decreasing.

I think there should be a small way to double the price of the closest to the original.

What I found is:

Double exact example

  0x 3ff0 0000 0000 0000 = 1 0x 3ff0 0000 0000 0001 = 1.0000000000000002, next high number & gt; Here, you can see that the next high number has been obtained by increasing the binary content of 0x 3ff0 0000 0000 0002 = 1.0000000000000004    

. But I do not think it works double because it continues to work:

Enter image details here I think that when all the fraction bit is set to one, then something else should be done to increase the volume.

Perhaps this is the name of the operation? Interesting reference?
Any information is welcome: D

thanks

Here, you can see that the next higher number is obtained by increasing binary content. But I do not think that it will continue to work because the double scheme looks like this:

[Picture left]

I think that something else

To do the first approximation, yes, it does work.

Consider the generalized positive number: This is a value m * 2 e where 1 < = m & lt; 2, i.e. m = 1.xxxxxxx (in binary). " 1 " before the binary point is omitted in the stored value, hence the part of the "fraction" (or "mantissa" or "importance") of the stored value are bits after the binary point.

We think that there are only 4 bits in the part part, instead of 52: stored value 1111 (binary) excerpt m = 1.1111 (binary) It is considered to be an integer, and moving it takes a fraction of 0000 .

But in the exponent carrying, it goes, which increases it. This is absolutely correct: after 1.1111 * 2 e , we expect that the next number is 10.0000 , which is actually 1.0000 * 2 E + 1 !


I called "first approximation" ... ... converting the representation into an integer, increasing and converting back again works well for positive normalized numbers. Positive also works for denormalised numbers (smaller than the smallest generalized number; these have an exponent of 0 and which is usually hidden).

If you also have integer representation, then it works for negative numbers; sign-magnitude; For those who do not usually have it more typical, you have to give a reduction to "increase" a negative increase.

Eventually, you will overflow the most generalized numbers and extend the exponent to infinity and NAN range.

There is an interesting article that includes it.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -