Re: how to make a decimal a power of ten?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: cody (deutronium_at_gmx.de)
Date: 01/18/05


Date: Tue, 18 Jan 2005 17:06:43 +0100

Yes that will do it!

"Niki Estner" <niki.estner@cube.net> schrieb im Newsbeitrag
news:ePZbY2W$EHA.4004@tk2msftngp13.phx.gbl...
> "cody" <deutronium@gmx.de> wrote in
> news:OwPQctW$EHA.3596@TK2MSFTNGP12.phx.gbl...
> >I want to do some validation of data field something like the following:
> >
> >
System.Diagnostics.Debug.Assert(decimal.Truncate(this.GesamtPreis*100)==this
> > .GesamtPreis*100);
> >
> > so that Iam sure that no more than a certain number of decimals are
> > stored,
> > but I don't want to hardcode them I want that the user can set how many
> > decimals are stored?
> >
> > I cannot use Math.Pow() since it works with double instead of decimal so
I
> > have rounding errors.
>
> Why don't you use "decimal.Round(x, NumberOfDigits) == x"? Wouldn't that
do
> what you want?
>
> Niki
>
>



Relevant Pages

  • Re: how to make a decimal a power of ten?
    ... >I want to do some validation of data field something like the following: ... > so that Iam sure that no more than a certain number of decimals are ...
    (microsoft.public.dotnet.general)
  • Re: how to make a decimal a power of ten?
    ... >I want to do some validation of data field something like the following: ... > so that Iam sure that no more than a certain number of decimals are ...
    (microsoft.public.dotnet.general)
  • how to make a decimal a power of ten?
    ... I want to do some validation of data field something like the following: ... so that Iam sure that no more than a certain number of decimals are stored, ...
    (microsoft.public.dotnet.general)
  • Re: Double: 2 Decimal points
    ... but on mainframes financial applications tend to ... This does avoid the rounding errors in adding ... In generaly, b/c floating point does not properly represent all decimals, ...
    (comp.lang.java)
  • Re: Floating point problem .....................
    ... you're going to get rounding errors. ... > i used calculators and other calculation mathods to see the actual ... > i also know that to hold exact decimals of we use f for float and m for ... > float fVar=100.1002f; ...
    (microsoft.public.dotnet.languages.csharp)