Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Must always round down or up

New Here ,
Feb 16, 2018 Feb 16, 2018

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!

TOPICS
Acrobat SDK and JavaScript
288
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 02, 2018 Mar 02, 2018
LATEST

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines