Skip to main content
January 13, 2021
Question

Valued getting changed to exponential

  • January 13, 2021
  • 3 replies
  • 2 views

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. ?

    3 replies

    mikes0011
    Brainy
    January 13, 2021

    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.

    The Expression Guru
    January 17, 2021


    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.

    mikes0011
    Brainy
    January 18, 2021

    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

    The Expression Guru