|
On Jul 5, 1:25 pm, "samira " <samira.rash...@gmail.com> wrote:
> Hi all
> I am making a logical comparison between two computed values and then perform a command based on the results of the comparison.
>
> Unfortunately, as I checked my code, I got that it doesn't use the whole number in the momory and uses the round of that number, for example this number is stored in the memory 1.173205080756888, but when it want to use this number for calculation it uses 1.1732. Therefore, it results error in logical comparison and affect my codes results.
>
> Can you help me to make my code use the exact values stored in memory?
>
> Thanks
Don't do it that way.
Do it like this:
if abs(y-x) < tol
% This means y is almost the same as x
end
where tol is a number small enough for it to work, e.g., 1e-3
|