Hi
i am having an issue with a calculation involving either putting a number value or a date value into a text field based on another conditional field value.
the calculation is:
if (life_type == ‘Days’)
{
return utils.dateFormat(date, ‘dd-MM-yyyy’);
}
else if (life_type == ‘Cycles’)
{
return cycles;
}
this is working fine for a date value into the text field. if it is putting a number into a text field it works fine most of the time but occasionally if the number is for eg. 19474.3 the value in the calc text field will be 19474.299999999! This happens only occasionally and i cannot consistently reproduce it.
The original number value is correct, only when servoy tries to calculate it into a text field is there this issue. I have tried using a fomat eg.
if (life_type == ‘Days’)
{
return utils.dateFormat(date, ‘dd-MM-yyyy’);
}
else if (life_type == ‘Cycles’)
{
return cycles | “#####.#”;
}
this produces a value of eg. 19474.0! but what i want is 19474.3
There is a numberFormat fx is that what i need? would appreciate any help