Author Topic: Detailed Modulus Discussion  (Read 7461 times)

0 Members and 1 Guest are viewing this topic.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Detailed Modulus Discussion
« on: March 28, 2012, 09:04:29 am »
Hi everyone,
This is a follow up to the 15Puzzle thread
http://ourl.ca/15678#quickreply
where I asked to clarify what % meant (modulo)

I was aware that % might mean modulo, however someone's equation for modulo was confusing me a bit.

% Stands for modulo (though it can have other uses too)

a % b == a - math.floor(a/b)*b

Luckily Xeda helped me out a bit (and also ruler in the background :P):
Code: [Select]
[05:43:41] <+OmnomIRC> (O)<Xeda112358> Yeah, are you familiar with modulo?
[05:44:28] <+OmnomIRC> (O)<Xeda112358> It is the remainder after a division, so when you do A-2floor(A/2), you get the remainder after dividing by 2
[05:46:41] <+OmnomIRC> (O)<Jonius7> I know it's the remainder, however need to work out how A-2floor(A/2) works out to be the remainder
[05:46:55] <+OmnomIRC> (O)<Xeda112358> Ah, okay
[05:47:12] <+OmnomIRC> (O)<Xeda112358> So, say you divide a number by 2 and you drop the decimal
[05:47:39] <+OmnomIRC> (O)<Xeda112358> When you multiply by 2, you have the highest number up to A that is divisible by 2
[05:47:48] <+OmnomIRC> (O)<Jonius7> Oh I've got it I think
[05:47:56] <+OmnomIRC> (O)<Xeda112358> :D
[05:48:06] <+OmnomIRC> (O)<Jonius7> I'll draw a diagram and post it somewhere
[05:48:22] <+OmnomIRC> (O)<Xeda112358> *cough* posting addiction *cough* ?
[05:48:42] <+OmnomIRC> (O)<Jonius7> Oh. Everyone's been noticing lol
[05:48:46] <+OmnomIRC> (O)<ruler501> Its not an addiction till you have >500 a month :P
[05:49:09] <+OmnomIRC> (O)<Xeda112358> Anywho, by definition, A=2N+B
[05:49:12] <+OmnomIRC> (O)<Jonius7> well yes and no.
[05:49:15] <+OmnomIRC> (O)<Xeda112358> For some N and B
[05:49:19] <+OmnomIRC> (O)<Jonius7> depends how long you get addicted ruler
[05:49:39] <+OmnomIRC> (O)<Jonius7> Yeah
[05:50:06] <+OmnomIRC> (O)<Xeda112358> So (A-2N)=B
[05:50:16] <+OmnomIRC> (O)<ruler501> Jonius7true
[05:50:19] <+OmnomIRC> (O)<Xeda112358> we find N by doing floor(A/2) :3
[05:50:33] <+OmnomIRC> (O)* Xeda112358 <3 math
[05:51:12] <+OmnomIRC> (O)<Jonius7> The A-2floor(A/2) works out the difference between the actual number and the floor of the quotient *multiplied by the floor of the quotient or something rather
[05:51:24] <+OmnomIRC> (O)<Xeda112358> yes
[05:52:07] <+OmnomIRC> (O)<Jonius7> yay. I really needed to understand that somehow.
[05:54:06] <+OmnomIRC> (O)<Jonius7> are modulo and modulus the same?
[05:54:43] <+OmnomIRC> (O)<Xeda112358> Pretty much
[05:55:04] <+OmnomIRC> (O)<Xeda112358> I just say "mod"
[05:55:19] <+OmnomIRC> (O)<Xeda112358> like "a mod b"
[05:59:46] <+OmnomIRC> (O)<Jonius7> I like modulus over modulo because I have seen it more often, but yeah, mod is good for shorthand
[06:00:17] <+OmnomIRC> (O)<Jonius7> or...
[06:00:28] <+OmnomIRC> (O)<Jonius7> Maybe modulus is the function, but modulo is the symbol
[06:00:45] <+OmnomIRC> (O)* Xeda112358 has to go to class D:
[06:32:11] <+OmnomIRC> (O)<Jonius7> meh modulus and modulo are different
[06:37:53] <+OmnomIRC> (O)<Jonius7> modulo is the whole function, whereas modulus refers to the remainder
Thanks to Xeda for that!
Also I said I would make a diagram and put it up here, so see how it goes!
I did want to put another diagram overall for the modulus but haven't done that yet.
EDIT: the diagram's a bit big. It's best to view it in a new tab :)
« Last Edit: March 28, 2012, 09:07:20 am by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Detailed Modulus Discussion
« Reply #1 on: March 28, 2012, 10:11:04 am »
I like the visual o.o

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Detailed Modulus Discussion
« Reply #2 on: March 28, 2012, 11:59:50 am »
So BIG!
A bit too much to read it entilery wihout scrolling :/

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Detailed Modulus Discussion
« Reply #3 on: March 28, 2012, 12:01:58 pm »
Open it in another tab and it will scale to fit :)

Offline harold

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 226
  • Rating: +41/-3
    • View Profile
Re: Detailed Modulus Discussion
« Reply #4 on: March 28, 2012, 01:58:00 pm »
Wowow wait. The modulus is not the remainder. It often is, but not when negative numbers are involved. The modulus has the sign of the divisor, the remainder has the sign of the dividend.
Blog about bitmath: bitmath.blogspot.nl
Check the haroldbot thread for the supported commands and syntax.
You can use haroldbot from this website.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Detailed Modulus Discussion
« Reply #5 on: March 28, 2012, 02:32:53 pm »
Yeah I would make the image smaller if I was you. Maximum 900 pixels width preferably.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Detailed Modulus Discussion
« Reply #6 on: March 28, 2012, 02:33:48 pm »
Hmm, in mathematics, when we look at -1 mod 5, that is 4, not sure if that helps...

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Detailed Modulus Discussion
« Reply #7 on: March 28, 2012, 05:21:58 pm »
Wowow wait. The modulus is not the remainder. It often is, but not when negative numbers are involved. The modulus has the sign of the divisor, the remainder has the sign of the dividend.
The given formula works for that. To use the example in Xeda's most recent post:
In -1 mod 5, -1 is the dividend and 5 the divisor. Then, -1 mod 5 = -1 - floor(-1/5)*5 = -1 - (-1)*5 = -1 - -5 = -1 + 5 = 4.
But the use of the word "remainder" in the quoted explanation is somewhat misleading, yes. As most of the time people are working with positive numbers, though, it's not that bad.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Detailed Modulus Discussion
« Reply #8 on: March 28, 2012, 07:01:32 pm »
Sorry if I made some mistakes. I am still not 100% certain about both the modulo and modulus.
Also it is big, which is why I said view in a new tab, but shall scale it down when I next update it.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)