numeric type conversion question

  • Thread starter Thread starter sonic_soul
  • Start date Start date
S

sonic_soul

I've been doing a litle research and running some test cases and all
seems ok, but just to be sure i wanted to ask for some advice
regarding type conversion...


basically my site was using money in the database, and float / int /
double .NET types to represent it on the site.


I converted most of it to use decimal type to represent money.


Now my question is this:

Since i still need to mutliply numeric sums (decimal) by quantity
(int) will this be ok ?


MyDecimal = SomeDecimal * SomeInt ???

also should i cast the int ?

MyDecimal = SomeDecimal * (decimal) SomeInt

also,

Also i'm doing SomeDouble = (double)myDecimal
and SomeDecimal = (decimal)Mydouble
which seems to work out ok.

for boxed objects im using

SomeDouble = Convert.ToDouble((decimal)Session["myDecimal"]) since
boxed objects do not allow casting to another type.

please let me know if you have any comments regarding any of theese
conversions.
TIA
 
let me add another cast to list of cast examples i wanted to verify
would be ok.

MyDecimal = (decimal)SqlReader.GetDouble();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top