12-18-2008, 10:35 PM
double d=9/2
at first calculates 9/2. Both are integers, therefore result is integer (4). Then it is assigned to d.
to calculate as doubles, use 9/2.0 or 9.0/2 or 9.0/2.0 or 1.0*9/2 etc.
at first calculates 9/2. Both are integers, therefore result is integer (4). Then it is assigned to d.
to calculate as doubles, use 9/2.0 or 9.0/2 or 9.0/2.0 or 1.0*9/2 etc.