# LiveCycle Designer

Currently Being Moderated

## Rounding to nearest multiple of 0.5 keeping 0.25 as the deciding factor

### Jun 22, 2012 12:58 AM

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

Replies
• Currently Being Moderated
Jun 23, 2012 4:22 PM   in reply to sandeep_joseph

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;

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

|
Mark as:
Actions

#### More Like This

• Retrieving data ...

#### Answers + Points = Status

• 10 points awarded for Correct Answers
• 5 points awarded for Helpful Answers
• 10,000+ points
• 1,001-10,000 points
• 501-1,000 points
• 5-500 points