Operator DIV

Dutch
2010-04-07
2010-04-07
  • Dutch - 2010-04-07

    Some months ago I had this working just fine!

    Suddenly have developed amnesia on how to use the DIV Operator and end up with a decimal number.

    As in 32767/32767=1

        32767/22222=1.474529
    
        22222/32767=.6781823
    

    I have tried every combination of data type: INT, WORD, REAL you name it.

    I can only ever end up with a 1 or a 0.

    IN1 and IN2 are Presently WORD at %IW0 and %IW2

    Can anyone refresh my memory?

     
  • Nitrozin - 2010-04-07

    Hi,

    try this.

    FUNCTION DIVI : REAL
    VAR_INPUT
    Β  IN1: WORD;
    Β  IN2: WORD;
    END_VAR
    VAR
    END_VAR
    DIVI := WORD_TO_REAL(IN1) / WORD_TO_REAL(IN2);
    

    regards Nitro

     
  • Dutch - 2010-04-07

    Thank you for the quick reply.

    Issue is solved.

    I had declared IN1 AT %IW0: REAL;

    Went over this 100 times. Turns out I had a corrupt

    version.

    Started a new one, everything's fine.

     

Log in to post a comment.