Skip to main content
Participant
February 25, 2024
Question

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

  • February 25, 2024
  • 1 reply
  • 136 views

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???

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
February 26, 2024

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.