Re: Rounding Numbers

Niclas123
2013-10-03
2013-10-05
  • Niclas123 - 2013-10-03

    Try build a FB like this one, it should do the work.

    value := (input MOD 10);
    IF value <> 0 THEN
    Output := input + (10 - (input MOD 10));
    ELSE
    Output := input;
    END_IF
    

    /Niclas

     
  • Niclas123 - 2013-10-04

    NP, sure.

    value := (input MOD 10);
    IF value > 5 THEN
    Output := input + (10 - (input MOD 10));
    ELSE
    IF value = 5 THEN
    Output := input + (10 - (input MOD 10));
    ELSE
    IF value < 5Β  THEN
    Output := input - (input MOD 10);
    ELSE
    Output := input;
    END_IF
    END_IF
    END_IF
    

    /Niclas

     

Log in to post a comment.