AW: [Mono-list] Maths
Tue, 10 Feb 2004 09:56:31 +0100
On Tue, 2004-02-10 at 09:36, Jochen Wezel wrote:
> Well, I hadn't imagined that there are several rounding standards.
> Here in Germany I only learned to round up each something.5 to the next integer at school.
> Now, I've seen the bank rounding which round up and down.
> But what I want to do is not bank rounding but scientific rounding: always round up every .5 to the next greater integer. Does anybody know how to do that? System.Math.Round doesn't support any flags to set up the rounding standard :(
hmm, i'm not a dotnet expert, but this is usually solved by adding 0.5
to it and truncating it to an integer.
Convert.ToInt32( x + 0.5)
p.s: pay attention to negative numbers. i'm not sure what behaviour you
want for negative numbers.