Copy link to clipboard
Copied
Hi
I am struggling to round down decimel numbers in fields to prevent the default to round up - ie: if I have 4 decimel places: 0.0000 and I type in 0.34567 - I need the field to round down the nearest decimel point: 0.3456 rather than the default of rounding up to 0.3457.
Is there a way I can do this in acrobat?
Place the function as a doc-level script, and as the custom validation or calculation script of the field enter this:
if (event.value) event.value = roundDown(Number(event.value), 4);
Copy link to clipboard
Copied
You can use this function to do it:
function roundDown(v, nDecimals) {
return Math.floor(v * Math.pow(10, nDecimals)) / Math.pow(10, nDecimals);
}
And you then call it like this:
roundDown(0.34567, 4);
Copy link to clipboard
Copied
thank you Try67 - how do I place this in the text field properties?
Copy link to clipboard
Copied
Place the function as a doc-level script, and as the custom validation or calculation script of the field enter this:
if (event.value) event.value = roundDown(Number(event.value), 4);
Copy link to clipboard
Copied
Brilliant - works perfectly! Thank you so much for your excellent skills!! 🙂