When an Attribute (Numeric, 2 Decimal Places) Field is Set to Show Only 1 Decimal Place in the View & an Even Number is Entered into the 1st Decimal Place Followed by a 5 in the 2nd Decimal Place & Saved, Rounds Incorrectly
Steps to Reproduce:
- Login as Administrator
- Go to the Project Object
- Create a new attribute with Data Type = Number and Decimal Places = 2
- Go to the Application Side, and click on Projects
- Select the Configure Icon
- Move the attribute 'Num Test' from the Available Column to the Selected Column
- Click the List Column Section drop down, and select Fields
- Click on the Properties Icon for 'Num Test'
- Change Decimal Places to 1
- Save and Return to the Project List
- Now go back and perform an inline edit of the new 'Num Test' field to see the rounding correctly performed by entering 1.15 (note first place of the decimal is an odd number)
See that the resulting number rounded up correctly to 1.2, as you would expect
- Now perform an in-line edit of the new 'Num Test' field to see the field round incorrectly by entering 1.25 (note first place of decimal is an even number):
See that the resulting number rounded down incorrectly to 1.2 instead of 1.3 as you would expect
Expected Result: .25 or any whole number with .25 displays as .3
Actual Result: .25 or any whole number with .25 displays as .2
In general, we use the default Java rounding method which is called ROUND_HALF_EVEN is explained here.
Some examples here:
So .25 will round down while .35 will round up.