----- Original Message -----
> long millisInMonth = (long)1000 * 60 * 60 * 24 * 30;
> This should probably go in some sort of Java-puzzle magazine article.
> :-)

I think this is a standard situation in Java and C. Most programmers would
probably write it as

long millisInMonth = 1000L * 60L * 60L * 24L * 30L;

only casting "(long)1000..." is safe only as long as the remainder of the
expression fits an int.

Use non-captital "l" rather than "L" as in

long millisInMonth = 1000 * 60 * 60 * 24l * 30; // right
long millisInMonth = 1000 * 60 * 60 * 241 * 30; // wrong

for Your Java puzzle. Depending on the font used it may be impossible to
spot the error ;-))



Reply via email to