Table of Contents
About the Calculator
Overview of Operation
The X Argument Field and the Y Argument Field
Data Functions
The Results Field
The Status Field
The Operations
Memory Locations
Viewing the JavaScript Code
Note Regarding Real Numbers and Precision
Note Regarding Calculation Times
Reporting Errors
Back to the Calculator!
About the Calculator (Back to the top of the page)
Why in the world would you need one of these? Fact is, there are lots of good uses for a calculator of this sort. For example, powers of 2 can be very useful, but try calculating 2256 on your pocket calculator. Accurately. See what I mean? I've known people to use this calculator for multiplying large primes. Prime numbers, of course, aren't typically expressed with any accuracy using ordinary calculators.
This Calculator has also offered me a great way to build a nifty li'l app using JavaScript (which I think is way underrated!) and to dredge up old forgotten math lore.
Finally, on a more philosophical note, I happen to really like the idea that there's this free-to-use tool out on the web. Why install more software on your computer when you already have a working browser? Why should you have to worry about which platform you're running, or which OS? As long as you have a browser that runs JavaScript, you have this new tool (and others that I'm planning -- just you wait!). The Calculator runs in your browser, with your computing cycles. I just supply the one-time-per-session download. How cool is that?
Overview of Operation (Back to the top of the page)
Unlike calculators with limited screens, you can enter and view two different arguments more-or-less simultaneously. There isn't an "invisible" stack. There are two fields, "X" and "Y" and the buttons clearly tell you what they'll do with the fields.
Another thing you can do that isn't as easy in a handheld calculator is a huge display. The largest number I've copied out of the Results window was a 5000-digit number (or thereabouts).
I can copy the Result from the window and paste it into any other application on my computer. Or, I can stash it in one of the ten Memory Locations, which are also things you won't see too much of on a handheld calculator.
The X Argument Field and the Y Argument Field (Back to the top of the page)
The Argument Fields are HTML "textareas". They can contain quite a lot of digits. The largest digits I've used in these fields have been about 2500 characters long. You can select the value in these fields and paste them into another application in accordance with your operating system. You wouldn't want to paste back into this application, of course -- that's what the Data Functions buttons do with single mouse-clicks.
Data Functions (Back to the top of the page)
Each argument has associated with it four Data Function buttons, which are located to the right of the Field (unless you're viewing the Calculator cross-eyed, in which case the Data Function buttons appear between two identical copies of the Argument Fields and to the right of all four components).
| Copy the contents of the associated Field to the Field specified on the button. | |
| Exchange the contents of the associated Field with the contents of the Field specified on the button. | |
| Multiply the contents of the associated Field by (-1). | |
| Delete the contents of the sssociated Field. I considered having these buttons set the associated Field to value of 0, but decided 0 was far too volatile to just be tossing around, so this button makes the Field empty. |
The Results Field (Back to the top of the page)
The Results Field is another HTML "textarea" and as such can contain quite a lot of digits, too. You can copy from this Field to other places in the Calculator with various button-presses. You can also copy out of this Field to some other application, such as something made for-profit by a company who requires that you install their software on your machine before you could use it. Not that I'm naming names.
The Status Field (Back to the top of the page)
The Status Field generally contains one of two strings: "Calculating..." or "Done!". The former stays around when the Calculator is working on a particularly tricky problem (such as 2512). This is your indication that the Calculator has at least started the process. Also, some browsers don't readily repaint the window if you decide to go off and play Snood (my one digital vice, alas...) during a long calculation, which is why "Done!" appears at the end.
The Operations (Back to the top of the page)
The most "dynamic" part of the document...
| Adds the two Arguments and displays the results in the Results Field. | |
| Subtracts the value in the Y Field from the value in the X Field and displays the results in the Results Field. | |
| Multiplies the two Arguments and displays the results in the Results Field. | |
| If the two Arguments are identical, then prints TRUE in the Results field. Otherwise, prints FALSE. | |
| Compares the values in the X Argument Field and the Y Argument Field. If X is greater than Y, returns TRUE in the Result Field, otherwise returns FALSE. | |
| Compares the values in the X Argument Field and the Y Argument Field. If X is less than Y, returns TRUE in the Result Field, otherwise returns FALSE. | |
| Performs an integer division, discarding the remainder. For example, If X = 9 and Y = 4, then X DIV Y = 2 because 4 divides 9 twice, with a Remainder of 1 (which is discarded). | |
| Performs an integer division, discarding the quotient and returning the remainder. For example, If X = 9 and Y = 4, then X MOD Y = 1 because 4 divides 9 twice, with a Remainder of 1. | |
| Compute the square of the value in the X Argument Field. Mathematically: X2. | |
| Compute the square of the value in the Y Argument Field. Mathematically: Y2. | |
| Compute the value in the X Field to the power of the value in the Y Field. Mathematically: XY or (X * X * X *...) Y times. | |
| Compute the value in the Y Field to the power of the value in the X Field. Mathematically: YX or (Y * Y * Y *...) X times. | |
| Compute the Factorial of the value in the X Argument Field. Factorial is defined as n! = (n - 0) * (n - 1) * (n - 2) * ... * 1. | |
| Compute the Factorial of the value in the Y Argument Field. Factorial is defined as n! = (n - 0) * (n - 1) * (n - 2) * ... * 1. | |
| Determines the Floor of the Square Root of the value in the X Field. | |
| Returns a TRUE if the value in the X Field is a perfect square (a square of an integer), otherwise returns FALSE. | |
| Ceiling rounds up to the next highest Integer. | |
| Floor rounds down to the next highest Integer. | |
| Calculates the Greatest Common Divisor, which is the largest Integer that divides both arguments. If the GCD is 1, then the numbers are said to be relatively prime. GCD will only function on positive non-zero Integers. | |
| Calculates the Least Common Multiple, which is the smallest Integer that is a multiple of both arguments. LCM will only function on positive non-zero Integers. | |
| This function checks for primality. For details of the algorithm, examine the JavaScript code. Basically, it checks a few "division shortcuts" first. Then it checks all odd numbers sequentially below the square root of the Argument. If it finds one, it stops immediately and reports FALSE. So, the longer it's taking, the more likely the argument is prime. I'm open to faster algorithms on this, by the way... | |
| Transfer the contents of the Results Field to the specified Argument Field. | |
| Erase content from the Results Field. | |
| Erase content from the Argument and Results Fields. |
Memory Locations (Back to the top of the page)
There are eight Memory Locations, such as this one, you can use to store results. When you press a Memory Button, the contents of the Memory Location and the contents of the Result Field are swapped. The face of the Memory Button will change to reflect the new content (well, the first few digits, anyway). When the application starts, all Memory Locations contain "0".
Viewing the JavaScript Code (Back to the top of the page)
I'm really not in the mood to hide the code, so if you want to see it, download the external JavaScript file (you may have to right-click and do a "Save as..." and then open it in a text editor). I don't mind people using the Calculator or referring others to it, but if you're of the mind to use parts or the whole thing in a commercial or for-profit application, please contact me -- you might be surprised at how reasonable I can be!
Note Regarding Real Numbers and Precision (Back to the top of the page)
At the moment, I have made a deliberate choice to not employ such Reals as the decimal representation of 1/3. I have run across a variety of online calculators that allow you to do such calculations and allow you to specify the level of precision you prefer. I might go that route, but not right now. I rather like the weird little niche this calculator fills and I like that I can tell someone "It's exactly as precise as you ask it to be." This is why I use the DIV and MOD functions, instead of the "/" operator, for example.
Note Regarding Calculation Times (Back to the top of the page)
If it's complicated, it's going to take a little time to complete. Your OS may complain that the browser wants more memory. This is as it should be. You deserve it for multiplying two 2500-digit numbers, or for trying to calculate 999 (which, by the way, I've never tested. I understand the answer has on the order of 350 million digits). If it's taking too long, go wash that damn coffee cup out and make a fresh pot for the crew.
Reporting Errors (Back to the top of the page)
By all means, please report errors to me! I want this calculator to be as accurate as possible, given the limits of the environment, but not given the limits of my dunderheadedness. People who find and report errors are thankfully noted in the code.