This is quite basic regarding converting types. Can someone help me understand the difference between these two statements assuming x1 and x2 are of type DOUBLE..
1 2
int t = x1 + x2;
int t = int(x1 + x2);
Are they equivalent? Is the latter better practice for some reason? (I ask because way 2 is the example given in my book but I'm wondering why you wouldn't do it the first way to save typing as much).
Yes, in effect. Both require a narrowing conversion from double to int. int t = x1 + x2; results in an implicit conversion from double to int. int t = int(x1 + x2); the conversion is explicit (functional cast notation).