Request: Add FLOOR, CEILING, and MROUND to the Math Instruction

In Excel, if I need to round a number to the nearest 0.5 for example I can use: MROUND(cell, 0.5). It would be extremely helpful to be able to use these sorts of things in both Productivity and Do-More. Maybe you already can in Do-More, IDK but it wouldn't surprise me. lol. I gave it a quick attempt there and the Math told me it doesn't recognize them so I'm just guessing I can't there.

 

Anyway, it would be nice to be able to do this in Productivity Math:

 

FLOOR(tag, 0.25) = round down to the nearest .25 value

CEILING(tag, 0.5) = round up to the nearest .5

MROUND(tag, 0.5) = round up or down to the nearest .5

 

example:

ExcelExamples 


  • HOST_franji1 (HOST Engineering)

    Got the 3 functions in MATH (FLOOR, CEILING, MROUND).

     

    Got identical results as you except for the MROUND(4.15, 0.1). The PLC 32 bit float is not as precise as the 64 bit double precision in the PC, so the PLC ended up with 4.1, not 4.2.

     

    The Memory View below is laid out the same as your Excel Results table:

    MROUND1This will be in the next major release (2.10).

    Expand Post
    Selected as Best
  • ADC Community_02 (Automationdirect.com)

    Thanks for your feedback! I will forward your suggestion over to the Productivity and the Do-More Product Managers.

  • HOST_franji1 (HOST Engineering)

    Here's is a work-around for FLOOR(number, significance), where R1 is number and R2 is significance

    (TRUNC(R1 / R2) * R2)

     

    and a work-around for MROUND(number, multiple), where R1 is number and R2 is multiple:

    (ROUND(R1 / R2) * R2)

     

    CEILING cannot be done correctly using existing TRUNC and ROUND functions.

    Expand Post
  • Durallymax (Customer)

    A workaround for Psuite (which you likely already have your own), is messy but just uses MOD.

    Screenshot 2022-12-07 164441

  • HOST_franji1 (HOST Engineering)

    Got the 3 functions in MATH (FLOOR, CEILING, MROUND).

     

    Got identical results as you except for the MROUND(4.15, 0.1). The PLC 32 bit float is not as precise as the 64 bit double precision in the PC, so the PLC ended up with 4.1, not 4.2.

     

    The Memory View below is laid out the same as your Excel Results table:

    MROUND1This will be in the next major release (2.10).

    Expand Post
    Selected as Best
    • PouchesInc (Customer)

      That is really awesome! Thank you so much for adding those and so quickly. This is why I love the people at Host and the BRX platform so much. 😁