Is the following code meaningful? Please answer in detail.
REAL Y=2.0, X=1.0, E=1.0; DO (E=E/2.0; Y=X+E; ) WHILE (Y<>1.0) Is the following code meaningful? Please answer in detail.
REAL Y=2.0, X=1.0, E=1.0; DO (E=E/2.0; Y=X+E; ) WHILE (Y<>1.0) The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .
The binary representation of y contains only two single bits: the first (the integer part is equal to 1) and one more, distant from the first by some power of two. First it is 1.1 , then 1.01 , 1.001 and so on. Theoretically - to infinity. But computer real numbers have limited accuracy. As soon as that bit is outside this precision, a number of 1 obtained.
I note that in this code, all operations except addition are performed absolutely exactly.
The similar code on javascript performs 53 iterations (this is the double digits of the mantissa):
var y=2, x=1, e=1; do { e /= 2; y = x + e; } while (y !== 1); Source: https://ru.stackoverflow.com/questions/513132/
All Articles