Wrong mathematics

2015-11-06
2015-11-06
  • PhilipLykov - 2015-11-06

    Hello,

    VAR
    outR: UDINT;
    END_VAR

    outR:=1024/255255100/100;

    Why outR = 1020 but not 1024?

     
  • PhilipLykov - 2015-11-06

    I studied math at school.
    Unfortunately the operations order doesn't mater here. I believe the problem somewhere in data types.

     
  • PhilipLykov - 2015-11-06

    I find out the problem: 255 is not a 256 and all calculations was done in integer type.

     

Log in to post a comment.