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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
decimal n3 = (decimal) (n1 / n2);