cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 28 Jul 2014 09:30 PM |
While scripting one day not too long ago from today, I stumbled across something unique and magical. Although this thread isn't necessarily about scripting, I can't really think of a better place where people might know the answer to this elsewhere and I got 0 replies on other non-roblox forums.
Anyways, I noticed that when I got the remainder of a number less than 65536, I got a value that is all the nibbles in that number added up.
For example: 51 % 15 = 6 (11 0011 % 1111 = 110)
Look carefully at the number represented in base 2, when you add up each nibble (in this case, 0011 + 0011) you get what would of been that number mod 15. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 28 Jul 2014 09:31 PM |
| That forum is all spam, I would just get troll replies if I went there. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 28 Jul 2014 09:32 PM |
Now that I think about it, I doubt the number matters. I'm pretty sure it can be >= 65536 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
ehern11
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1541 |
|
|
| 28 Jul 2014 09:54 PM |
| how do you open the developer panel :> |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 29 Jul 2014 11:44 AM |
When cntkillme has a problem, SH cries.
I have no idea what you're talking about, man |
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Jul 2014 11:46 AM |
| Really this should be in Scripters, you are more likely to find someone who knows there. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 29 Jul 2014 11:54 AM |
But notun, people like CoolioTree hang out there D: Have you seen this, too: http://www.roblox.com/Forum/ShowPost.aspx?PostID=141791446 |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 29 Jul 2014 12:01 PM |
| Yeah, what happens in Scripters... I can't go there and expect any answer worth reading |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 02 Aug 2014 05:32 PM |
cntkill
you're the best guy here mate but I'm pretty sure you're one of the smartest
so no one knows what you're talking bout
sorry |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 05:35 PM |
It works in decimal and hexadecimal also:
51 mod 9 = 5 + 1 = 6
#33 mod #F = 3 + 3 mod #F = 6
And, I would guess, any other base |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 05:38 PM |
| It's called 'casting out nines' in dec |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 06:05 PM |
| Yeah I know that but like, how/why does it work? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 06:10 PM |
I don't think it works in all bases for the most part. In hexadecimal for sure but if I do
10 % 15 I get 10, but 1 + 0 = 1
In hex it works out perfectly: A % F = A |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 06:11 PM |
Wait, ignore my last post it does work in all cases. I'll see if there is a wikipedia entry about it |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 06:13 PM |
So if you have a number, let's say 515, it can be represented by
5*100 + 1*10 + 5
==
5*(99+1) + 1*(9+1) + 5
== (5*99 + 1*9) + 5 + 1 + 5
However, the (5*99 + 1*9) is a multiple of 9, so when you take the modulus it doesn't affect the remainder, so you get
515 mod 9 == (5*99 + 1*9) + 5 + 1 + 5 mod 9 == 5 + 1 + 5 mod 9 == 11 mod 9
(and then repeat --> 1+1 mod 9 == 2)
The fact that it works by adding up it's nibbles is just because you're switching bases around |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 06:17 PM |
So basically: number % (base - 1) = sumofeachpart % (base - 1)? 156 % 9 = 12 % 9 3 = 3
Woah that's actually neat. Thank you. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 06:18 PM |
| part being the digit of a number (or in any other base, the appropriate term). |
|
|
| Report Abuse |
|
|