Rounding inconsistency in repeating table

FedWorker

13-03-2018

In our LiveCycle Designer form design we have a repeating table with a Total field. The total is rounding some numbers up and not rounding other numbers. For example:

58.81 x 42.5 = 2499.43 which is correct.

60.49 x 5.5 = 332.69 which is incorrect - it should be 332.70.


The JavaScript formula we are using is:

this.rawValue = OTRate.rawValue * Hours.rawValue

Any ideas on what is going on here???

Accepted Solutions (0)

Answers (5)

Answers (5)

_Bruce_Robertson

MVP

22-03-2018

I've never noticed this before, sorry for the bum steer.  I did test this in IE 11, as I always thought javascript maths worked the same, but seems IE 11 is the only one that returns 332.70, Edge, Chrome and FF return 332.69.

Maybe try

(OT.rawValue * Hours.rawValue + 0.001).toFixed(2)

I guess it has something to do with the rounding of a decimal ending in 5.

FedWorker

14-03-2018

I'm confused. If using the field names I have above (not static numbers as in your example), would this be:

(OT.rawValue * Hours.rawValue).toFixed(2)

??


Because that doesn't work under the calculate function of LiveCycle Designer.

MinusZero

13-03-2018

Hi,

There is a rounding function in Livecycle, but only for FormCalc.

However, even it does some strange things. Your calculation comes to 332.695 but rounding to 2 digits gives the answer 332.69, not 332.70

Apparently Adobe dont understand how to Round.

Round

Evaluates a given numeric value or expression and returns a number rounded to a given number of decimal places.

Syntax

Round(n1 [, n2])  

Parameters

Parameter

Description

n1  

A numeric value or expression to be evaluated.

n2 (optional)

The number of decimal places with which to evaluate n1 to a maximum of 12.

If you do not include a value for n2, or if n2 is invalid, the function assumes the number of decimal places is 0.

Note: FormCalc follows the IEEE-754 international standard when handling floating point numeric values. For more information, see Number literals.

Examples

The following expressions are examples of using the Round function:

Expression

Returns

Round(12.389764537, 4) 12.3898
Round(20/3, 2) 6.67
Round(8.9897, "abc") 9
Round(FV(400, 0.10/12, 30*12), 2)

904195.17. This takes the value evaluated using the FV function and rounds it to two decimal places.

See also FV.

Round(Total_Price, 2)

Rounds off the value of Total_Price to two decimal places.