He says that we need to ensure that the values that are multiplied really are multiplied using long datatypes, not multiplied as int datatypes and later converted to long. The L suffix on the 1000L integer literal ensures this. My question is what difference does it make if they they are multiplied as int datatypes and later converted to long??
posted 13 years ago
If you compute 150000000 * 1000 as integer the result will be bigger than Integer.MAX_VALUE. Actually if you compile the code and run it, you can see that mFromSun yields -323855360 However, if you compute the value as a long you get the correct result...