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
  • Ok now I changed 2 things and it looks good so far.

    1. Changed ri!inp type to ANY (this actually reversed the problem. if I enter 25.57889555 it worked fine but when I enter 25.1 and saved, process variable showed 25.100000000000001)

    so I assumed the problem is with todecimal() function that I used to wrap FIXED(). I removed that wrapper and now both the case seems to work. But FIXED() returns a TEXT and its getting saved into a Number(Decimal) rule variable. But I dint get any error when saving into.

    So can anyone suggest if its good to go with this.

    Now my rule got changed into
    = if(
    or(
    isnull(
    ri!inp
    ),
    todecimal(
    ri!inp
    ) = 0
    ),
    null,
    fixed(
    ri!inp,
    2
    )
    )
Reply
  • Ok now I changed 2 things and it looks good so far.

    1. Changed ri!inp type to ANY (this actually reversed the problem. if I enter 25.57889555 it worked fine but when I enter 25.1 and saved, process variable showed 25.100000000000001)

    so I assumed the problem is with todecimal() function that I used to wrap FIXED(). I removed that wrapper and now both the case seems to work. But FIXED() returns a TEXT and its getting saved into a Number(Decimal) rule variable. But I dint get any error when saving into.

    So can anyone suggest if its good to go with this.

    Now my rule got changed into
    = if(
    or(
    isnull(
    ri!inp
    ),
    todecimal(
    ri!inp
    ) = 0
    ),
    null,
    fixed(
    ri!inp,
    2
    )
    )
Children
No Data