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
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)) ) ) )
You are aware that fixed() returns a string and you are back into an auto type conversion cycle?
Yes, but I haven't ran into any issues using fn!fixed (without fn!trunc), and I use it in a number of locations within a Purchase Request/Order application and elsewhere.
This is not keeping up to two decimal places.
I agree with Chris and James
I don't think the todecimal is really necessary.
a!floatingPointField( label: "Test Decimal Value", value: ri!value, saveInto: { a!save( ri!value, if( a!isNotNullOrEmpty(save!value), fixed(save!value, 2), null ) ) } )
More info found in this KB article: https://community.appian.com/support/w/kb/707/kb-1426-unexpected-results-on-decimal-calculations-and-rounding