299.65 is automatically converting to 299.64.

Certified Associate Developer

Hi,

Whenever I'm trying to enter 271.64 or 2**.65 where (** can be any number) it's getting converted to 2**.64

I'm using below expression for this:

a!floatingPointField(
label: "Test Decimal Value",
value: todecimal(fixed(trunc(ri!value, 2))),
saveInto: ri!value
)

Not sure, if this is an issue from Appian. Can anyone confirm this.

Thanks in advance.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Fascinating bug you found there.  

    From my testing, the issue seems to be with the trunc() function, fixed() does not exhibit the same behavior. 

    I recommend reducing your expression to: fixed(ri!value, 2)

    It is not necessary to use todecimal(), as the a!floatingPointField() performs the cast as well.

    So, right now, you are truncating as a floating point number, converting to a string, and setting a fixed number of characters, then converting BACK to a floating point number, for a field than then casts to a floating point number automatically.  A few more steps than necessary, I should think.

    Take care,

    JM

  • I agree with fixed() only, and I would place the 'conversion' on the saveInto vs the display, try:

    EDIT:  Code updated

    a!floatingPointField(
      label: "Test",
      value: ri!value,
      saveInto: a!save(
        ri!value,
        if(
          rule!APN_isEmpty(save!value),
          0.00,
          todecimal(fixed(save!value,2))
        )
      )
    )

Reply Children