Here's a similar solution, but no temp variables are needed.
Uses variables('myFloat') to represent the number you want to round.
div(
add(
mul(variables('myFloat'), 1000),
sub(
if(
greaterOrEquals(
mod(mul(variables('myFloat'), 1000), 10),
5
),
10,
0
),
mod(mul(variables('myFloat'), 1000), 10)
)
),
1000
)
Or, all in one line:
div(add(mul(variables('myFloat'),1000),sub(if(greaterOrEquals(mod(mul(variables('myFloat'),1000),10),5),10,0),mod(mul(variables('myFloat'),1000),10))),1000)The float is multilpiled by 1000 before doing modulo to avoid tiny-fraction math errors (e.g. returning 0.00499999... instead of 0.005).
Using add, sub, mul, div, and mod to round a float... a reasonable workaround... XD
If you're looking for an expression to format for currency with a thousands separator, see my expression in another post.