loop issue-Solved
|
06-15-2023, 07:24 PM
(This post was last modified: 06-15-2023 08:55 PM by Amer7.)
Post: #1
|
|||
|
|||
loop issue-Solved
Hi,
I'm having an issue writing. I need a loop that will compare if the number is >360, then it will subtract -360, then compare if the number is greater than 180 if it is then -180, else +180; Code: EXPORT numbers() -I use a while loop to make it subtract -360 when the number is greater than 360 Then I compare the number IF its >=180 then -180, else +180. But it's not working WHILE M0(i+1,2)>360 DO /// While its >360 subtract -360 M0(i+1,2):=M0(i+1,2)-360; ---- Memorize it IF M0(i+1,2)>=180 THEN ----- Compare if the memorized value is>=180 M0(i+1,2):=M0(i+1,2)-180; ------ THEN -180 ELSE IF M0(i+1,2)<180 THEN -----If the memorized value vas <180 M0(i+1,2):=M0(i+1,2)+180; ADD +180 END; END; END; Example Result The program does this: 71+320= Compares it the correct result should be 211 and it is Next row, 211+10=231 compare it, the result should be 51(231>180 then 231-180=51) next row, 51+20=71 compare it, result should be 251(71<180 then 71+180=251)... EDIT SOLUTION Code: EXPORT numbers() |
|||
06-18-2023, 02:03 PM
Post: #2
|
|||
|
|||
RE: loop issue-Solved
Isn't it easier to use the division algorithm?, that is, take the remainder of the division of the sum of angles with 90 degrees: irem(71+320+10+20+171,90) returns 52
|
|||
06-25-2023, 12:32 AM
Post: #3
|
|||
|
|||
RE: loop issue-Solved | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)