Thanks Peter, that is very detailed. In my case, I have to deal with amounts
that are always doubles with two decimals. Since I need to add these
numbers, but only after transforming them to integers, I do not have to
implement my own rounding routine. I need however to prevent the
introduction of rounding errors...
From: Discussion of advanced .NET topics.
[mailto:ADVANCED-DOTNET@DISC...]On Behalf Of Peter Vertes
Sent: Monday, August 25, 2008 12:59 PM
To: ADVANCED-DOTNET@DISC... Subject: Re: [ADVANCED-DOTNET] Converting doubles into integers without
If you are ready to make your head spin take a look at these pages:
On Mon, Aug 25, 2008 at 12:51 PM, Curt Hagenlocher
> On Mon, Aug 25, 2008 at 9:48 AM, Peter Ritchie
> <advanced.dotnet.discuss.develop.com@pete...> wrote:
> > I would recommend something like this:
> > double tempAmount = objMyObject.Amount * 100.0;
> > uint nIntAmount = Math.Round(tempAmount);
> Ah, *that*'s where the rounding function is hiding.
> Or you could just use "Math.Round(amount, 2)" to round to the second
> decimal place.
> Curt Hagenlocher
> curt@hage... >
> This list is hosted by DevelopMentor(R) http://www.develop.com >
> View archives and manage your subscription(s) at
> http://discuss.develop.com >