You are not logged in.
Pages: 1
Topic closed
Hi All,
I've had a good search of the function block manual. I can't seem to find a block that will round a number up to a desired amount of decimal places.
I'm willing to make one up or something that works but I'd prefer to use a standard block if one exists.
Cheers
Mike
Offline
Hi Mike,
thank you for this interesting question. I must say that there is no specific function block which does the thing. However, it is definitely possible to achieve such behaviour.
One option is to convert the Real number to String and then back to Real - function blocks RTOS and STOR. Be sure to setup RTOS parameters according to desired amount of decimals and to select mode "2:normal".
Other option is to multiply the real number by (desiredAmountOfDecimals)x10, then round by means of RTOI function block and finally divide by (desiredAmountOfDecimals)x10. Function block sequence is therefore MUL, RTOI and DIV.
Hope it is useful for you.
Cheers, Tomas
Offline
Hey Tomas,
Thank you for your help as always. I have used both methods (just to be different!) and created subsystems for future use.
Thanks again.
Mike
Offline
Pages: 1
Topic closed