5 Replies Latest reply on Feb 13, 2018 1:05 PM by paigen17377757

# Always round decimal up to whole number

How do I set a formula to always round up to a whole number?

I am not sure if this is the right place but I am creating a fillable PDF that uses a lot of formulas. This specific formula needs to always round up to the next whole number. For example, if the formula comes back as 14.01 it would still need to round up to 15. Does anyone know if I need to do a custom validation script for this? Or how to do that?

Thank you!!!

• ###### 1. Re: Always round decimal up to whole number

Do you use a script for the calculation, or some other means?

• ###### 2. Re: Always round decimal up to whole number

I use a simplified field notation:

(Text27/Text124) + 1

• ###### 3. Re: Always round decimal up to whole number

Since you're dividing by the value of a field you should use a custom calculation anyway, and it will also allow you to round the result.

```var v1 = Number(this.getField("Text27").valueAsString);
var v2 = Number(this.getField("Text124").valueAsString);
if (v2==0) event.value = "";
else event.value = Math.ceil((v1/v2) + 1);
```
• ###### 4. Re: Always round decimal up to whole number

Ok that is really close!

For some reason, it rounds up to one more number than needed. For example, 7.63 rounds to 9.00 instead of 8 and 3.81 rounds up to 5.00 instead of 4. Any ideas on why?