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

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

New Here ,
Feb 25, 2024 Feb 25, 2024

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

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