In K&R (second edition) in section 4.9 (pg. 85) when discussing Initialization, an example of calculating the number of milliseconds in a day is given:
long day = 1000L * 60L * 60L * 24L
Why are long literals used here on the RHS of the assignment? In section 2.7 (Type Conversions) on pg 44 the following rules are given:
If either operand is
long double, convert the other to `long doubleOtherwise if either operand is
double, convert the other todoubleOtherwise if either operand is
float, convert the other tofloatOtherwise, convert
charandshorttointThen, if either operand is
long, convert the other tolong.
For the calculation of long day = ..., surely int literals could be used here? Would they not automatically be converted to long based on the rules above?
I wrote the following:
long day1 = 1000L * 60L * 60L * 24L;
long day2 = 1000*60*60*24;
Within the debugger, both day1 and day2 were long.
What was the purpose of using long literals?