I am making a code using fortran77.
I input 3.6. Strangely when I call the value, it gives me 3.5999.
Do you know how to fix this problem?
Please help me.
I need to use the value to calculate another value. I defined the value of 3.6 to "CA". The problem is that "CA" is called as 3.59999. It gave me wrong answer because the calculation is conducted with 3.5999.
I think you have a more serious problem of why you can get a "right" answer at 3.59999, but a "wrong" answer at 3.5999. The uncertainty in any real world scenario will swamp out this trivial precision error.
The issue is that you cannot get exactly 3.6, because it's not a binary number. Have you checked the numerical precision of your variables? Do you really expect people to know what you did in your program without a listing?
I appreciate your explanation.
I understand what you mean.
Frankly, I don't know how to check the numerical precision.
Could you let me know how to check?
It is a long time since I worked in FORTRAN - it was still called FORTRAN IV when I learnt it! Did you declare the TYPE for your variable CA? Try declaring it as DOUBLE PRECISION or whatever the equivalent is in FORTRAN 77. If you have enough 9's after the 5 the value becomes indistinguishable from 3.6
If you work with integer variables and divide 360 by 10, yes you would get 36, no problem.
But divide 36 by 10, with integer variables would give 3, with real variables (whether single or double precision) you would get something like 3.599999 or 3.600001, but never precisiely 3.6