Loops/While: Difference between revisions

Content added Content deleted
(Added Matlab Code)
Line 280: Line 280:
=={{header|Matlab}}==
=={{header|Matlab}}==
In Matlab (like Octave) the math is done floating point, then rounding to integer, so that 1/2 will be always 1 and never 0. A 'floor' is used to round the number.
In Matlab (like Octave) the math is done floating point, then rounding to integer, so that 1/2 will be always 1 and never 0. A 'floor' is used to round the number.
<lang Matlab>i = 1024;
<lang Matlab>
i = 1024;
while (i > 0)
while (i > 0)
disp(i);
disp(i);
i = floor(i/2);
i = floor(i/2);
end</lang>
end
</lang>


=={{header|MAXScript}}==
=={{header|MAXScript}}==