java - Why does this not result in 1000? -
possible duplicate:
java problem-whats reason behind , probable output
long milli=24*60*60*1000; long micro=24*60*60*1000*1000; long result=micro/milli;
the result should 1000 not. why work when use 24*60*60*1000*1000l
?
can tell me reason this?
the trouble calculation done on int
s , casted long
, , unfortunately 24*60*60*1000*1000 won't fit in int
, wraps around. like
long micro=24l*60*60*1000*1000;
to force last multiplication done on longs.
Comments
Post a Comment