Copy link to clipboard
Copied
We utilize a non conventional way of rounding and I would like to format the calculated fields in my form to this rounding method:
Example: 0.45 rounds to 0.4
0.35 rounds to 0.4
It's called "Odd to Even" rounding. If the place being rounded (tenths place) has a five in the hundredths place and the number in the tenths place is even it rounds down and if the number in the tenths place is odd it rounds up.
Any help would be greatly appreciated. Thanks!
Thank you Thom Parker and George_Johnson! Your direction has solved my issue. That link George shared did the trick once Thom pointed out that it had to be a document script. Then all I had to do was utilize that function in the custom formatting like I would anything else.
Copy link to clipboard
Copied
You'll need to write your own rounding function, and custom calculation scripts. Do you have any programming experience?
Copy link to clipboard
Copied
Not really. I have just begun delving into pdf programming this month. I've done a few things like auto imputing a future date and basic custom calculation. I'm learning as I go.
Copy link to clipboard
Copied
The rounding function should be a document script, so it's defined once and accessible to all other scripts in the PDF.
Did you want the actual value of the field to be rounded? or just how the value is displayed? This is important if the value is used in other calculations.
Copy link to clipboard
Copied
I'd like the displayed value to be rounded not the actual value because it is used in other calculations.
Copy link to clipboard
Copied
It's commonly known as "Banker's rounding", which may be helpful if you do a search for JavaScript code that accomplishes it, e.g.: Gaussian/Banker's Rounding in JavaScript · GitHub
Copy link to clipboard
Copied
Thank you Thom Parker and George_Johnson! Your direction has solved my issue. That link George shared did the trick once Thom pointed out that it had to be a document script. Then all I had to do was utilize that function in the custom formatting like I would anything else.
Copy link to clipboard
Copied
Glad you got all the pieces together. The custom format script is often overlooked.