Link to home
Start Free TrialLog in
Avatar of Dawkins
Dawkins

asked on

Quick question about casting to doubles

Hi all quick Java newbie question,

With a calculation like this:

----------code---------------
int ten = 10;
int three = 3;
double out = ten / three;
----------/code---------------

out will equal 3.  But if I cast *either* ten or three to a double , I get the correct result of 3.333333.

What is the correct thing to do?  Cast both to double(which seems logical) or only one(which minimises the amount of casting)?  

Or shouldn't I be getting into this situation in the first place?
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

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
persona = personal

;-)
Avatar of Dawkins
Dawkins

ASKER

ok thanks :)