Rounding to the nearest .5

J

Jeffshex

Does anyone know how to do this? I've tried adjusting the decimal place to
1, but that didn't auto round or anything. I have about 9 textboxes that
need to do this.
Any Ideas?
 
A

Alex [MSFT]

You can use rules to achieve this goal. Play with the "floor", "ceiling" and
"mod" XPath functions, they should help.
 
J

Jeffshex

Well, i see the "round" function, but I need it to go by the nearst .5
Also, I did not see a mod function.
Is this still possible?
 
J

Jeffshex

I guess I would want it to go to the nearest .5
That would probably work the best for me.

Greg Collins said:
Do you mean to the "nearest" .5 or to the "next" .5? For example, if you have 123.6, does that mean you want 123.5 or 124.0?

The above is more for curiosity than anything.

My recommendation would be that you don't use rules, but instead use code. I'm sure if there's a good mathematician here, they could give you some kind of a formula to do this, but it seems to me that writing code is just as easy. Then you have fine-grain control over such neuances as I mentioned above.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Well, i see the "round" function, but I need it to go by the nearst .5
Also, I did not see a mod function.
Is this still possible?

Alex said:
You can use rules to achieve this goal. Play with the "floor", "ceiling" and
"mod" XPath functions, they should help.
 
D

Databasic

Dim oldno as Decimal = 23
Dim newno = int(oldno.Round((oldno /10 * 2),0) /2 * 10)
Response.write(newno)
 
Top