I have a Payment screen where lot of calculations are done on the basis of some input and logic. The payment amount can not have more than 2 decimal precision. It is getting handled on UI .But while doing calculation some times values are giving exponential value or some invalid value which should not be the output. How to handle that, Should round function should be used or not. ?
Discussion posts and replies are publicly visible
Can you provide sample code and any specific examples of inputs, expected results versus actual results? Without this any answers here will mainly be based on blind guessing.
todecimal( 31914.60 ) - todecimal( 31914.40 )) - ( 0.2)
The above calculation is giving exponential value. Since these values is used further for some calculations and validations So it is getting a break.
and my requirement is that the value should not be more than 2 decimal precision. So I am using a round function and i also tried with round down function but it is not giving correct value in every case.
Decimals in Appian are known to not be super precise due to hidden decimal rounding issues inherent in Java (iirc). However when I use round() at least in your example above I do get the expected result of zero:
round( todecimal(31914.60) - todecimal(31914.40), 1 ) - 0.2