
1. Re: Help with rounding writing a function for rounding down.
try67 Jun 5, 2017 4:58 AM (in response to JMMurphy181)1 person found this helpfulTry this code as the field's custom calculation script:
var result = ((Number(this.getField("Field1").value)+Number(this.getField("Field2").value))10)/2; event.value = Math.round(Math.abs(result));

2. Re: Help with rounding writing a function for rounding down.
Test Screen Name Jun 5, 2017 6:20 AM (in response to JMMurphy181)Or did you mean that 3.5 rounds to 4?

3. Re: Help with rounding writing a function for rounding down.
JMMurphy181 Jun 5, 2017 6:46 AM (in response to Test Screen Name)Yes, so 3.5 to 4

4. Re: Help with rounding writing a function for rounding down.
JMMurphy181 Jun 5, 2017 6:58 AM (in response to try67)This kinda works, is there a way to make it work for negative numbers, like 3.5 to 4
Thanks btw for the help.

5. Re: Help with rounding writing a function for rounding down.
try67 Jun 5, 2017 7:11 AM (in response to JMMurphy181)That is more tricky because by default the rounds negative numbers that end with .5 down, while positive numbers get rounded up... You will need to use a custom rounding function to do that.
And to keep the negative numbers negative just remove the Math.abs() part of the code I posted above.

6. Re: Help with rounding writing a function for rounding down.
gkaiseril Jun 5, 2017 8:58 AM (in response to JMMurphy181)1 person found this helpfulYou might have to use the Math.floor method and not the Math.round method.

7. Re: Help with rounding writing a function for rounding down.
try67 Jun 5, 2017 9:53 AM (in response to gkaiseril)1 person found this helpfulThat would work, but it would round down any number... So 3.99 will become 3.0. I'm not sure that's what the OP is after.

8. Re: Help with rounding writing a function for rounding down.
JMMurphy181 Jun 5, 2017 12:12 PM (in response to JMMurphy181)Worked out perfectly, thanks for all the help guys.