Anyway to round down decimal variables in logic calculation?
round it like normal: {{ round(NUMBER) }}
round it up: {{ roof(NUMBER) }}
round it up: {{ ceil(NUMBER) }}
round it down: {{ floor(NUMBER) }}
Yes I did see this earlier but what i was wondering is that the function rond up you can specify how many decimals you want to round up on. The same method does not work with floor(VALUE,n).
Is this a limitation of the function " floor()"?
this is indeed a limitation of the build in logic’s calculation card, though that is of course very easy to fix with regular calculus:
1 decimal: {{ floor(NUMBER * 10) / 10 }}
2 decimals: {{ floor(NUMBER * 100) / 100 }}
etc
It might be possible with the “better logic library” app with the floor(VALUE, n)
way.
I have tried to execute the Floor command on BLL, but get an error. the code is:
{{floor((Number),0)}}
the error is: ReferenceError: floor is not defined
Any pointers?
I think the function is math.floor(number, decimals)
.
Source: math.js | an extensive math library for JavaScript and Node.js
so the correct usage in BLL is:
{{floor(number)}}. no need for the ,0
You need to add the Math. part.
Also if you use BLL’s calculate card (Voer uit) then you don’t have to use the leading and trailing braces:
Based on the earlier referenced documentation I understand that the default behaviour of this function is to round down to no decimals. So you can skip the ‘,0’. Note that if you do provide a decimal argument, the funtion still rounds down to no decimals in my case.
Stumbled across this useful thread, but there is a small error. To round up the correct function is math.ceil.
math.ceil(x)
math.ceil(x, n)
math.ceil(unit, valuelessUnit)
math.ceil(unit, n, valuelessUnit)
math.js | an extensive math library for JavaScript and Node.js