Doesn't math.floor() do what you want? 
________________________________

Ian Thomas
Victoria Park, Western Australia

-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of Alastair Waddell
Sent: Thursday, 17 June 2010 12:20 PM
To: ozDotNet
Subject: Math.Round

Hi All,

Does anybody know if it is possible to change the default behaviour of
the math.round function.

Out of the box is does this;

Dim number = 98.5
Dim RoundedNumber = Math.Round(number)

RoundedNumber = 98

What I want is to change the behaviour to 

Dim number = 98.5
Dim RoundedNumber = Math.Round(number, MidpointRounding.AwayFromZero)

RoundedNumber = 99

I would like my developers to not have to think about adding the Mode.


Now to save some of the arguments I KNOW we are going to have;

Yes - We could have code reviews to highlight when it is incorrect
Yes - FX Cop or similar
Yes - There are probably different / better algorithms
Yes - There are business reasons for this 


So

My question is can we change the default behaviour from 
Math.Round(number, MidpointRounding.ToEven)
To
Math.Round(number, MidpointRounding.AwayFromZero)



Alastair





Important Notice
This email contains information which is confidential and intended solely
for the use of the individual or entity to whom it is addressed.  Please
notify the sender immediately if you have received this e-mail by mistake
and delete this email from your system.  If you are not the intended
recipient, any form of distribution, copying or use of this communication or
the information contained or attached is strictly prohibited.  Although
Disability Services Commission has taken reasonable precautions to ensure no
viruses are present in this email, the Commission cannot accept
responsibility for any loss or damage arising from the use of this email or
attachments.


Reply via email to