|
Version 1.2 (released Mar. 17, 2007)
Introduction
This script simulates a pocket calculator. Have a look at this example:
Calculator
Instructions:
- Use the buttons or the number pad of your keyboard to enter numbers and operators.
NOTE: Opera and Firefox assign special functions to some keys of the number pad, so they
won't work with the calculator.
- Click "=" or press the [ENTER] key of your keyboard to view the result.
- Reset the calculator by clicking "AC" or pressing [ESC] on your keyboard.
- Delete the current input by clicking "CI" or pressing [DEL] on your keyboard.
- Delete one character of the current input by clicking "←" or pressing the left arrow
key on your keyboard.
- Click "Hex" to switch from decimal to hexadecimal mode.
- Click "Dec" to switch from hexadecimal to decimal mode.
- Close the calculator by clicking the X-button in the title bar or pressing [X] on your
keyboard.
NOTE: The shortkey doesn't work with Safari.
This script was tested with the following systems and browsers:
| Windows: |
 | IE |  | NN 7 |  | Opera |  | FF |  | Chrome |
| Mac OS X: |
 | IE |  | Safari |
If you use another browser or operating system, this script may not work for you - sorry.
Notes:
- The calculator looks strange in IE 5 on Mac OS, but it works. Opera has problems when
dragging the calculator, i.e. it selects the text underneath.
- Precision of floating point numbers is limited to 13 decimals. This is necessary because
JavaScript isn't very accurate with floating point numbers; for instance, when you add 0.2 to
0.1 with JavaScript, the result will be 0.30000000000000004 instead of the expected 0.3.
JS-Calculator tries to fix this by rounding and limiting the number of decimals. Exception:
numbers in exponential notation, e.g. 1.7953425537109374e-9.
Comments
|