I'm using an application, which offers a feature of creating user-defined functions. Available set of methematical operations which could be incorporated is rather small, namely I can use:
- addition
- substraction
- multiplication
- division
Also, I can use IIF control statement with the default signature of: IIF(expression,truePart,falsePart)
Now, my goal is to create a function which could calculate rounded values from input decimals. The precision is set to the second position from the decimal point. However, it would be very nice if the precision could be parametrized through some input argument to the formula.
For example, if the input variable holds value of 3.14159, then the result of the formula would be 3.14
Can you advice me on how to define this formula?
Given the poverty of the instruction set, this is barely possible.
If there is a known maximum possible value, say
32767, you can implement a floor function by dichotomic search.Then
x-disfloor(x).From that you derive
and
where scale is a power of
10.