The existing ROUND() function should be resulting in rounding off the given deci

The existing ROUND() function should be resulting in rounding off the given decimal number based on the specified number of digits in the second parameter. It works perfectly fine if we store the value in the TEXT data type variable, But, if we store the value in the Decimal data type, it is not behaving as expected. May i know the reason behind this? Are there any work around ? or is it a known issue?
Ex. Round(10.223434, 2) = 10.22 -> stored in the Text Variable
Round(10.223434, 2) = 10.219999999999995 --> stored in the Decimal Variable.

TA
...

OriginalPostID-119683

OriginalPostID-119683

  Discussion posts and replies are publicly visible

Parents
  • We are facing a similar issue. For display purpose we can use FIXED() or any other function. But we need to save the decimal value (after rounding the scale to 2 digits) into a decimal type variable.

    Code:
    --------
    a!floatingPointField(
    label: "Current Ratio",
    value: ri!agsTransactions_cdt.templateInfo.currentRatio,
    saveInto: {
    ri!agsTransactions_cdt.templateInfo.currentRatio << rule!BW_AGS_convertToDecimal(_)
    }
    )
                                  
                        
    Rule - BW_AGS_convertToDecimal                    
    ---------------------------------

    = if(
    or(
    isnull(
    ri!inp
    ),
    todecimal(
    ri!inp
    ) = 0
    ),
    null,
    todecimal(
    fixed(
    ri!inp,
    2
    )
    )
    )


    Here ri!inp is of type Number(Decimal).

    This is working fine when I enter something like 25.55 but when I enter something like 25.57888958988,
    in the screen it is rounding the value and displaying 25.58 but my process variable shows 25.580000000000002.
Reply
  • We are facing a similar issue. For display purpose we can use FIXED() or any other function. But we need to save the decimal value (after rounding the scale to 2 digits) into a decimal type variable.

    Code:
    --------
    a!floatingPointField(
    label: "Current Ratio",
    value: ri!agsTransactions_cdt.templateInfo.currentRatio,
    saveInto: {
    ri!agsTransactions_cdt.templateInfo.currentRatio << rule!BW_AGS_convertToDecimal(_)
    }
    )
                                  
                        
    Rule - BW_AGS_convertToDecimal                    
    ---------------------------------

    = if(
    or(
    isnull(
    ri!inp
    ),
    todecimal(
    ri!inp
    ) = 0
    ),
    null,
    todecimal(
    fixed(
    ri!inp,
    2
    )
    )
    )


    Here ri!inp is of type Number(Decimal).

    This is working fine when I enter something like 25.55 but when I enter something like 25.57888958988,
    in the screen it is rounding the value and displaying 25.58 but my process variable shows 25.580000000000002.
Children
No Data