|
|
 |
Re: FN-FORUM: .Net Simple(?) Maths Problem
date posted 8th February 2008 11:11
Phillip Healey wrote:
> Hopefully someone can give me an answer to what I imagine is a simple problem (if you know the answer) ;-)
>
> Basically I need to take an int and divide it by 10. However I need to round the answer up (not down) to the nearest whole number.
>
> Can anyone point me in the right direction please?
>
> P.s. I’m using c# / .Net 2
>
I don't know about the language specifics, but if you add 0.5 to the
interim answer before "rounding" the result you should get what you
want, e.g.
53 / 10 = 5.3
5.3 + 0.5 = 5.8
round(5.8) = 6
or
58 / 10 = 5.8
5.8 + 0.5 = 6.3
round(6.3) = 6
Assuming a ROUND function is available that rounds values 0.0 to 0.4
down and 0.5 to 0.9 up
Any use?
Nick
|
 |
|