
1. Re: Question regarding ROUNDING a number to nearest Quarter
try67 Dec 10, 2010 2:19 PM (in response to RoC1909)You description is not consistent. Why would 12.10 round down and 0.01 to
0.24 (which includes 0.10) would round up?

2. Re: Question regarding ROUNDING a number to nearest Quarter
try67 Dec 10, 2010 2:47 PM (in response to RoC1909)Here's a sample code I wrote to round a number (x) to the nearest quarter (new_x):
var x = 22.15;
var rounded_x = Math.floor(x);
var new_x;if (xrounded_x<=0.125) new_x = rounded_x; // 0  0.125 round down to 0
else if (xrounded_x<=0.375) new_x = rounded_x+0.25; // 0.125  0.375 round to 0.25
else if (xrounded_x<=0.625) new_x = rounded_x+0.5; // 0.375  0.625 round to 0.5
else if (xrounded_x<=0.875) new_x = rounded_x+0.75; // 0.625  0.875 round to 0.75
else new_x = rounded_x+1; // 0.875  1.00 round up to 1Edit: improved the code...

3. Re: Question regarding ROUNDING a number to nearest Quarter
RoC1909 Dec 10, 2010 2:33 PM (in response to try67)Ugh....stupid me. My brain was thinking of one thing, and my fingers of another. Please disregard that last example.

4. Re: Question regarding ROUNDING a number to nearest Quarter
try67 Dec 10, 2010 2:43 PM (in response to RoC1909)Thought so...
(see my second post to this thread)

5. Re: Question regarding ROUNDING a number to nearest Quarter
RoC1909 Dec 10, 2010 2:56 PM (in response to try67)Your code has really got me thinking (or the fact that I was OVER thinking this problem) and it gave me that "push" that I needed to tackle this.
Thank you very much for the prompt and extremely helpful answer!

6. Re: Question regarding ROUNDING a number to nearest Quarter
gkaiseril Dec 10, 2010 3:18 PM (in response to RoC1909)1 person found this helpfulA simple function like:
function MyRound(nValue, nRound) {
return Math.round(nValue / nRound) * nRound;
} // end MyroundWill compute the round value to the nearest nRound value. This function would not limit one to only the nearest 0.25 but could be any value like 1,000 or 0.01.
To round field "Text13' the custom calculation script could be:
event.value = MyRound(this.getField('Text13').value, 0.25);
or without the function:
event.value = Math.round(this.getField('Text13').value / 0.25) * 0.25;

7. Re: Question regarding ROUNDING a number to nearest Quarter
RoC1909 Dec 10, 2010 3:45 PM (in response to gkaiseril)Another tip that I can use.
Thanks for your help, George.