Skip to main content
Known Participant
February 19, 2016
Answered

How do I script to have a number like 12.25

  • February 19, 2016
  • 1 reply
  • 345 views

How do I script to have a number always with 2 characters left then dot then 2 decimal places

12.25

10.45

12.50

etc...

Thanks

This topic has been closed for replies.
Correct answer George_Johnson

You can use the util.printf method, for example:

var num = 123.456789;

var num_rounded = util.printf("%.2f", num);  // results in 123.46

More information is in the Acrobat JavaScript reference.

1 reply

George_JohnsonCorrect answer
Inspiring
February 19, 2016

You can use the util.printf method, for example:

var num = 123.456789;

var num_rounded = util.printf("%.2f", num);  // results in 123.46

More information is in the Acrobat JavaScript reference.