KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 30 Jan 2015 09:32 AM |
11 % 3 = 2
Found this in the Wiki.
Anyone mind telling me, wat exactly does this do??? I'm confused... I tried millions of things and it's like the Numbers are just Randomly Picked and Printed :/ |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 30 Jan 2015 09:35 AM |
| It returns the remainder when A is divided by B |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
| |
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 30 Jan 2015 09:53 AM |
| You know, like in primary school when you first learn to divide without knowing what decimals are. '2 goes into 5 two times, and there is one left over!' |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 30 Jan 2015 10:05 AM |
5 % 2
well, it is what's left of 5/2.
5/2 is 2 and 1 in rest. Or 2.5 but we won't do decimals unless the rest is decimals. |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2015 10:36 AM |
% is the remainder.
print(5/2) --> 2.5
print(5%2) -->1
So if their both division what the heck is the difference?
Let me show you:
print(5/2) --script is asked what 5 divided by 2 is, 2.5 * 2 is 5, so it returns 2.5
print(5%2) --script is asked how much is left over after putting 2 into 5 as many possibles --2*1 is less than 5 --2*2 is less than 5 --2*3 is more than 5 --5-(2*2) is 1, return 1 |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 30 Jan 2015 10:39 AM |
| yes i get it now, thnx guys |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2015 10:48 AM |
If you need a script to understand, I can replicate it for you:
function Modulus(n, n2) local remainder = n while remainder - n2 < 1 do remainder = remainder - n2 end return remainder end |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2015 10:49 AM |
| Please note my example only works with positives. |
|
|
| Report Abuse |
|
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
| |
|
| |
|
KAAK82
|
  |
| Joined: 06 May 2014 |
| Total Posts: 1166 |
|
|
| 30 Jan 2015 02:16 PM |
| warspy, u practicly always have a good answer |
|
|
| Report Abuse |
|
|
| |
|