I need to use Do loop with increment 0.1
Let's say that the variable X is defined between 1 and 11 with increment 0.1.
DO X = 1,11,0.1
....
END DO X
When I run this code, RATS gives error on "usage of real integer number" as an increment.
How can I use a decimal number as an increment in DO LOOP?
Thank you for your helps.
Use decimal number increment for the code DO LOOP
Re: Use decimal number increment for the code DO LOOP
You can't use DO with non-integers. Use the more general DOFOR:
Note that you really can't just ask to go from 1 to 11 by steps of .1 with machine arithmetic (which is why %SEQRANGE uses a count rather than an increment). Because .1 isn't represented exactly in binary, adding .1 100 times might or might not end up hitting 11 exactly. It will round to 11, but might actually be something like 10.99999999999.
dofor [real] x = %SEQRANGE(1,11,101) ?x end dofor
Note that you really can't just ask to go from 1 to 11 by steps of .1 with machine arithmetic (which is why %SEQRANGE uses a count rather than an increment). Because .1 isn't represented exactly in binary, adding .1 100 times might or might not end up hitting 11 exactly. It will round to 11, but might actually be something like 10.99999999999.