Which version are you using (my Vip7.3 behaves differently)?
Anyways, the following program shows the problem:
Code: Select all
run : ().
end class main
addTwoNo : (real, real).
Result = Input1 + Input2,
t : (real).
stdio::writef("%\t%4.20f\n", A, A).
end implement main
The program produce this result in Vip7.3 (and also in Vip7.4 (next release)):
Recall from my other mail that all reals cannot be represented, so any real may be represented by a near by number.
The result above shows that 6786.71 have a representation that is so close that it prints back in as itself (last line) even with many digits.
But the two other numbers apparently don't have a close representative. Furthermore, both of them are represented by smaller numbers than the original. So the sum will be too small (as seen in the third line).
If you have a real R then it will be represented by some real R' these two numbers are not always the same, the representation in the computer may introduce a little error e: R' = R + e.
When you add two numbers you will also add the errors, depending on their sign the overall error may thus increase or decrease. Furthermore, the addition may it self introduce additional error because the real result may use more bits than available.
We do not consider any of that as bugs, because it is a completely natural consequence of usingthe real representation that we do (which happens to be the one that the computer naturally use and efficiently supports).
So your program will have to
deal with the fact that reals are not precise.