Re: Variable type Money/Currency

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The help for CS0664 is pretty clear. By default, doubles cannot be
implicitly converted to decimal. 100.15 is considered a double. To
make it decimal write 100.15M:

deductionTotals += 100.15M;

http://www.peterRitchie.com/

tshad wrote:
> "Chris Dunaway" <dunawayc@xxxxxxxxx> wrote in message
> news:1126287869.237782.113620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > You'd probably be better off using a Decimal type
>
> But how do you add cents?
>
> I tried doing:
>
> deductionTotals += 100.15
>
> and got 2 errors:
>
> Literal of type double cannot be implicitly converted to type 'decimal';
> use an 'M' suffix to create a literal of this type
>
> and
>
> Operator '+=' cannot be applied to operands of type 'decimal' and
> 'double'
>
> Do I need to take all my calculations and multiply them by 100?
>
> Thanks,
>
> Tom
> >

.



Relevant Pages

  • Re: Printf problem with big numbers....
    ... > So I use "double" instead, and it is ok with calculations. ... [incidentally, %lf is not needed for printf, and is forbidden in c89] ... your doubles aren't precise enough? ... Prev by Date: ...
    (comp.lang.c)
  • Re: Variable type Money/Currency
    ... But how do you add cents? ... Do I need to take all my calculations and multiply them by 100? ... Tom ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C sucks at math? (help)
    ... I said I wouldn't try doubles in the real project, ... do similar calculations in a much bigger project and the problem I'm ... the floating point hardware or emulation does. ...
    (comp.lang.c)
  • Re: Java rounding with big Decimal.
    ... That is, more or less, what I meant by "inherently inaccurate". ... less error in calculations involving them than you might with ... I still say BigDecimals are better than doubles, ...
    (comp.lang.java.programmer)
  • Re: Advantage of using byte over Long Integer?
    ... J P Hill wrote: ... > I'm using an Access DB to do a series of calculations. ... > data are stored as doubles to maximise accuracy. ...
    (microsoft.public.access.tablesdbdesign)