Copy link to clipboard
Copied
So I'm useing this(thank you again to try67) to round to the nearest .25:
var a = this.getField("A").valueAsString;
if (a=="") event.value = "";
else {
var v = Number(a);
v = Math.round(v / 0.25) * 0.25;
event.value = v;
}
But I need it to always round up, sometimes for instance if I have 5.60 it'll round to 5.50 when I need it to round to 5.75. How can I do this?
Actually I figured it out, I just changed Math.round to Math.ceil
Copy link to clipboard
Copied
Actually I figured it out, I just changed Math.round to Math.ceil
Copy link to clipboard
Copied
Math.round is for integer values only. One can use the util.printf() method for rounding the actual values of the field and the Number format with the optional decimal place specification for the number of decimal places if only the displayed result needs to be rounded. JavaScript by default stores numeric values as floating point values. There also user written JavaScript functions to perform floating point rounding.