Rounding the variable to decimal places

In order to round the value of a number type variable to the selected decimal place, create:
* two variables of the number type in user features on CLU:



* script:

a = CLU->variable*10^decimal_places 
b = a - math.floor(a)

if(b>=0.5) then
CLU->variable1=math.ceil(a)/10^decimal_places
else
CLU->variable1=math.floor(a)/10^decimal_places
end


Where:
a, b - local variables in the script;
variable - variable value that we want to round;
variable1 - rounded value of the variable;
decimal_places - the number of decimal places to which the value of variable will be rounded (script parameter).


* script parameter:


Please note that in the Object Manager, values are always displayed with two decimal places, thus, to verify the correctness of the script execution is needed:

* adding an additional string variable in the CLU user features:

* adding a following verse at the end of the previously created script:

CLU->string1=tostring(CLU->variable1)