Calculation result separated in whole number and decimal, not rounding correctly
I have 2 fields for the result of a division: the whole number and the decimal (1 decimal). I Math.floor the result to get the whole number and all goes well until I hit a case where the result is 92.97.
This should give "93" in the whole field and "0" in the decimal field, instead it gives me "92" and "10" (even though I only allow 1 character in the field).
How do I get the "93" and "0" in the following code?
fieldLVEDV = this.getField("LVEDV").value;
fieldBSA = this.getField("BSA").value;
if (fieldLVEDV != "" && fieldBSA != ""){
totalLVEDV = this.getField("LVEDV").value + ((this.getField("LVEDVDec").value)/10);
calculation = (totalLVEDV / fieldBSA);
calculationDecimal = calculation;
partWhole = Math.floor(calculation);
if(partWhole <0) {partWhole ="";}
this.getField("Index").value = partWhole ;
this.getField("IndexDecimal").value = Math.round(10*(calculationDecimal-partWhole));
{if (this.getField("IndexDecimal").value = "10")
{
this.getField("Index").value = partWhole+1;
this.getField("IndexDecimal").value = "0"
}}
} else {
this.getField("Index").value = "";
this.getField("IndexDecimal").value = "";
}
I thought adding the blue part would do the job but obviously it didn't work.
