Skip to main content
jbornga-work
Known Participant
December 2, 2021
Question

Form which calculates square root of one field times a second field rounded up to a value

  • December 2, 2021
  • 1 reply
  • 824 views

I am trying to convert an excel spreadsheet to a fillable PDF form.  The sheet has the following equation to calculate a value with a certain number of significant figures and then round up to a given unit.  

CEILING(ROUNDUP($H$15*SQRT($H$18),2),$H$16))

I want to create a similar JAVA script of a field on the form "uncertainty" from the fields as follows:

H15=Ub

H18=Number

H16=dvalue

 

Any assistance would be greatly appreciated

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 2, 2021

First of all, it's JavaScript, not Java.

- The square root of a number can be calculated like this:

Math.sqrt(x)

- There's no built-in command in JS that allows to round up to a specific number of digits, but you can create your own function that will do it.

- Rounding up to the nearest integer can be done like this:

Math.ceil(x)

jbornga-work
Known Participant
December 2, 2021

Thank you for your prompt response, as you can see I am not very familiar with javascript (note my inserting a space between Java and script in the initial post).  

What would the resulting script look like to take the square root of the value in field "number" and multiply it by the value in "Ub" with the Math ceiling of the value in the field "dvalue"?

 

try67
Community Expert
Community Expert
December 2, 2021

Sorry, I see now that the CEILING function in Excel also takes a parameter to round up to a specific multiple.

That doesn't exist in JS as a built-in function, either. You'll need to create your own formula to do it.