Link to home
Start Free TrialLog in
Avatar of rajesh_khater
rajesh_khater

asked on

Divide 2 long values and get a decimal result

How can I divide 2 long values and get result in decimal?

long n1 = 7;
long n2 = 2;
decimal n3 = n1/n2;

I get n3 = 3, whereas it should be 3.5. Whats wrong and how to correct it?
ASKER CERTIFIED SOLUTION
Avatar of jonorossi
jonorossi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try

decimal n3 = (decimal) (n1 / n2);