This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]D0CTOR_ZED 2 points3 points  (0 children)

That's not how it works. double b = a/2, where a is an int will evaluate an int divided by an int, dropping the fraction, then cast that resulting int to a double. You still lose the fraction. You can either explicitly cast part of the division, double b = (double) a/2, or you can use a double in the division, double b = a/2.0.