Hi,
> On 22 Apr 2018, at 22:46, Jacek Sobczak <
boni...@gmail.com> wrote:
>
> Hi,
>
> Compare these two loops:
>
> for k=0:0.1:1.3; k, end
> for k=0:0.1:1.4; k, end
>
> On my free copy of sysquake 6.0.1 (Windows and Linux) both iterate 14 times. The iteration for 1.4 in the second one is not done. What's wrong here?
0.1 cannot be represented exactly with a 64-bit floating-point number. Adding it 14 times exceeds slightly 1.4, so the second loop stops one step before. Try e.g.
sum(repmat(0.1,1,14)) * 10 - 14
ans =
1.7764e-15
To be sure to have 15 iterations, you can use integers:
for k10 = 0:14; k = k10 / 10, end
Or linspace:
for k = linspace(0, 1.4, 15); k, end
> And by the way - is there anything I can do to prevent a figure-windows on Linux to load the procesor to 100%? On Windows the load is barely 5%.
It might be a bug. We'll check that. Thanks.
Best,
Yves