« Refa Tandoori Indian Restaurant, Melksham | Main | Upgrade Mac OSX to Leopard, Web Server Apache httpd config lost »

November 28, 2007

Question on division (Java) - Also Perl, PHP, Python ...

Q:

What's the difference between % and /?

A:

/ returns the result of a division
% returns the remainder when you do a division.

Divide 18 by 7 you get 2, with a remainder of 4 (i.e. 4 left over).

so 18/7 give 2, and 18%7 gives 4.

Posted by gje at November 28, 2007 02:47 PM

Comments

Post a comment




Remember Me?


Well House Consultants Ltd. Copyright 2008