Skip to main content
debraj25034221
Participant
April 5, 2017
Question

Add numbers with 3 or more decimal places and round up total

  • April 5, 2017
  • 1 reply
  • 2612 views

I've got several fields that calculate a * b= c.  I'm having a heck of a time trying to add these numbers and round up the total to only 2 decimal points (e.g. 1.625 + 1.3264 = 2.9514) total should be 2.95.  Can anyone help me?

Thanks,

Deb

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
April 5, 2017

You can use this code as the custom calculation script for "c":

var a = Number(this.getField("a").value);

var b = Number(this.getField("b").value);

event.value = (a+b).toFixed(2);

debraj25034221
Participant
April 5, 2017

I'm still having trouble.  Here's what I'm trying to do:

115.5*1.15 = 132.825    (the total rounds up and displays 132.83)

195.25*.95 = 185.4875  (the total rounds up and displays 185.49)

The total shows 318.31

I want the displayed numbers in BOLD to total 318.32

try67
Community Expert
Community Expert
April 5, 2017

You need to better define the logic of when it should round up and when down, then...