This week's giveaway is in the Android forum. We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line! See this thread for details.

When one number is divided by another number, First binary numeric promotion occurs: If one number is a double, the other number is promoted to a double. Otherwise, if one number is a float, the other number is promoted to a float. Otherwise, if one number is a long, the other number is promoted to a long. Otherwise, both numbers are promoted to type int. Now, both numbers are of the same type. If both numbers are integral (type int or type long), ordinary math division occurs and the result is rounded toward 0 to the nearest integer. Sometimes this is called truncation. If both numbers are floating point (type float or type double), ordinary math division occurs and the result is rounded to the nearest number of type float or type double. There are a lot of special cases for floating point arithmetic. They are defined in the standard IEEE 754-1985. For example, 1/3 Both numbers are of type int. The result is 0.333333333 etc. The result is rounded to 0. For example, 1.0f/3.0f Both numbers are of type float. The result is 0.333333333 etc. The result is rounded to 0.33333334, because it is closer than 0.33333330. The numbers 0.33333331, 0.33333332 and 0.33333333 do not have a floating point representation. [ June 01, 2003: Message edited by: Marlene Miller ]

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.

subject: Assigning fractions to primitive integral/decimal types?