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

Round Down and Round Up depending if numbers are negative or postive.

New Here ,
Feb 25, 2024 Feb 25, 2024

Copy link to clipboard

Copied

event.value = this.getField("X").value / (10); event.value = Math.floor(event.value);

I have this case of script but if "X" is negative i would like the script to change and round up instead of rounding down the result. I have no idea on how to do so, can someone help???

TOPICS
Edit and convert PDFs , How to

Views

52

Translate

Translate

Report

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
Community Expert ,
Feb 26, 2024 Feb 26, 2024

Copy link to clipboard

Copied

LATEST

Use this code:

 

var x = Number(this.getField("X").value) / 10; 
if (x<0) x = Math.ceil(x);
else x = Math.floor(x);
event.value = x;

 

In the future post such questions in the Acrobat forum, please, not the Reader one.

Votes

Translate

Translate

Report

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