Skip to main content
Participant
February 16, 2018
Question

Must always round down or up

  • February 16, 2018
  • 1 reply
  • 327 views

Hi Team,

I need assistance for 2x Custom calculation scripts for the following as Simplified field notations will not work(As far as I'm aware).

I'm currently using these two Simplified field notations with 6x Text Fields,

A = Number

B = Number

C = Number

D = Number

E = Simplified field notations: A / (B + C)

F = Simplified field notations: D / E

However E must always round down and F must always round up.


Eg, E = 1.8 the script will make it 1

Eg, F = 1.2 the script will make it 2

Please help!

This topic has been closed for replies.

1 reply

Inspiring
March 2, 2018

I doubt that you can do the division you you want in the Simplified Field Notation since Acrobat's JavaScript treats the result as a NaN,, Not a Number. This is because any field that is blank is treated as having a null value or zero value. You can verify this  by clearing your form and see the message that is displayed. Then set the result feilds' format to "None" and observe the displayed result. The only option for the calculation is to use the Custom JavaScript calculation and use an "if" statement to exclude any division by zero.

JavaScript has a number of methods of the Math object that can round an integer, truncate to the next closet integer (floor), or round up to the next largest in tiger (ceil).