These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

I don't want this calculation to Round!

bauerkm
Registered: Jan 24 2011
Posts: 3

I am using Adobe Livecycle Designer 8.0. I have created a simple formula and I need it to show only three decimal points. It keeps rounding the last decimal point though and for accounting reasons I don't want that. Please help.
 
The calculation is this
 
form1.#subform[4].CurrentRateofPay * form1.#subform[4].NumericField1
 
Where form1.#subform[4].CurrentRateofPay = 12.56 and form1.#subform[4].NumericField1 = 1.03
 
The answer is actually 12.9368 and I just want it to show up as 12.936. Is this possible??? Any help would be appreciated.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

use a pattern to control the decimal points.

num{zzzzzzzz9.999}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Not only do you need to control the decimal points displayed, but you need to truncate the value to 3 decimal places and not banker round the value to 3 decimal places. Setting the display pattern to 'z,zzz,zz9.999' will still round as will setting the trailing decimal places to 3 will do. You need to truncate at the 3rd decimal place.The 'Floor' function can truncate a value to the next lowest integer. Since you want to truncate to 3 decimal places, you need to sift the decimal location, truncate, and then adjust the result back to the 3rd decimal place.

You can use the following calculation script to truncate the computed value at 3 decimal places. It temporarily sifts the decimal place for the truncation and then returns the decimal place back to the original position.

Floor( (form1.#subform[4].CurrentRateofPay * form1.#subform[4].NumericField1) * 1000) / 1000


Or if you want to specify the number of decimal places:

var nDec = 3 // decimal places for rounding
Floor( (form1.#subform[4].CurrentRateofPay * form1.#subform[4].NumericField1) * Pow(10,3) nDec) / Pow(10, nDec)

The Pow function returns base to the exponent power, that is, base ** exponent. So Pow(10, 3) is 10 cubed or 1,000.

Make sure to set the display format or trailing decimal places for 3 decimal places.

George Kaiser