Modulo Arithmetic
Posted by David Wees on Nov 13, 2006
One problem I've noticed with calculators in general is that they don't do Modulo arithmetic. This is normally not needed by the typical person, but comes in handy for solving some interesting number theory problems.
So I quickly (like 5 minutes) created this modulo calculator below.
View it here.
Popular content
- Gradient jQuery plugin (33,134)
- Modulo Arithmetic (8,980)
- Using Red 5 Flash media server with Drupal (5,876)
- Interactive Venn diagrams using JavaScript (5,478)
- Javascript Algebra solver (4,275)
- Histograms Online (4,167)
- Javascript Puzzle Creator (4,027)
- Creating Equations in Movable Type (3,971)
- Game of Life ported to Flash (3,872)
- Flash Compass (3,867)
- 1 of 13
- ››
Comments
This
This is pretty much useless, it doesn't work.
Well that's a pretty useful
Well that's a pretty useful piece of feedback. I can definitely use the information you have provided to improve my script. I have no idea why you are 'pissed' though since it's a free script. Not able to do your homework assignment?
Maybe you could provide the following to be useful.
[none]
I'm sorry the only other comment here is from a jerk.
Your app is really useful-- but is it handling negative numbers correctly? -5 should be equal to 7 mod 12, right?
Good job otherwise.
Yeah you are right, -5
Yeah you are right, -5 should be equal to 7 mod 12. If my script isn't working it's because the % modulo JavaScript operator is returning the wrong value.
Since this is one of my most popular pages, I should probably fix that bug (which should be pretty simple to do).
Dave
This should be fixed now,
This should be fixed now, negative values should work. Interesting that JavaScript's implementation of Modulo is actually incorrect for most negative cases.
just one minor question, if
just one minor question, if I want to calculate a large number to a large power, mod to a large number, without doing it by hand... it seems like the app doesn't have that feature...
im actually working on a problem, which is 141^128 mod1000, trying to figure out what that is....
Yeah I remember doing stuff
Yeah I remember doing stuff like that when I was learning number theory in university. You want to follow the instructions here to do this type of calculation.
http://en.wikipedia.org/wiki/Modular_exponentiation#Memory-efficient_method