Operator '*' cannot be applied ... ¡?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello -
float r;
r = (int)(Number * Math.Pow(10, Decimals) + 0.5) / Math.Pow(10, Decimals);
Error:
Operator '*' cannot be applied to operands of type 'decimal' and 'double'

//data sample
int Decimals = 2;
Decimal Number = 123.258; //has to be decimal

What's happen here?
 
double cannot be implicitly coverted to decimal; it needs an explicit cast:

Number * (decimal)(Math.Pow (10, Decimals) + 0.5)...

Hello -
float r;
r = (int)(Number * Math.Pow(10, Decimals) + 0.5) / Math.Pow(10, Decimals);
Error:
Operator '*' cannot be applied to operands of type 'decimal' and 'double'

//data sample
int Decimals = 2;
Decimal Number = 123.258; //has to be decimal

What's happen here?
 
Back
Top