Dear All,
How could I round amounts as illustrated by the following examples in Adobe Livecycle Designer?
8.06 = 8.00, 8.26 = 8.50, 8.74 = 8.50, 8.76 = 9.00
Thanks,
Sandeep
Views
Replies
Total Likes
Hi Sandeep,
I don't think there's any trick to doing this, you just have to test and adjust the values yourself, something like;
app.alert(roundToNearestHalf(8.06));
app.alert(roundToNearestHalf(8.26));
app.alert(roundToNearestHalf(8.74));
app.alert(roundToNearestHalf(8.76));
function roundToNearestHalf(number)
{
var result = Math.floor(number);
var fraction = number - result;
if (fraction >= 0.75)
{
result++;
}
else
{
if (fraction > 0.25)
{
result += 0.5;
}
}
return result;
}
Regards
Bruce
Views
Replies
Total Likes