
calc-extension bởi Martin Väth
Calculate values of mathematical expressions
34 người dùng34 người dùng
Siêu dữ liệu mở rộng
Ảnh chụp màn hình


Về tiện ích mở rộng này
The extension strives to be useful for everybody quickly needing
brief or mid-long calculations: in daily “browser” life, as a
mathematician, or as a programmer - there is support for all needs.
Formulas can be entered in the typical mathematician's or programmer's syntax - both is understood. There is also support for lengthy sessions (saving/restoring, exporting to clipboard, etc).
The original motivation was to experiment with a Pratt parser.
There is already a much richer expression syntax than in most languages
(implicit multiplication signs, no braces necessary for function calls),
and it would be simple to extend the syntax to a more full-blown “language”.
(In fact, earlier versions of calc-extension had a simpler syntax.
Readers interested in the parser implementation can check
After installing calc-extension, it can be used as follows.
Click the calc-extension symbol
Then a page opens where you can enter a formula (see below) which will be
calculated when you press the solver button (
(There is an option to use the enter key instead if you prefer.)
The result is then shown and you can enter the next formula.
You can also go back to an earlier entered formula and “recalculate” it
(e.g. after you modified some variables).
To remove a formula from your list, simply remove the main formula text
and press the solver button.
A simple formula is a usual mathematical expression which consists of numbers, the usual operators
As usual in mathematics (though not in most computer languages),
it is possible to omit the multiplication sign.
However:
Be aware that
For multiplication use instead one of the symbols
The division symbol is
Numbers have the usual floating-point format, e.g.
There are further operators which can be used in expressions:
Note that functions bind stronger than all binary operators, i.e.
Furthermore, there are constants available:
Finally, it is possible to define variables with e.g.
Variable names must only consist of English characters, numbers, or
The whole syntax and operator precedence is inspired by javascript.
However, the following things are new.
There is a special variable name
the last (succesful) calculation.
There are also special sequences which can occur anywhere in an expression
and which cause options to switch (you can also switch them by the mouse).
To modify options more permanently (also for future sessions even across
browser restarts), you have to set them in the preferences window.
The actual calculation of the functions and number conversion occurs
by javascript calls. Therefore, mathematical properties like available
precision, error messages, number limitations, and possible inaccuracies
(and possibly even bugs) are inherited from the javascript interpreter.
Example session
Permissions
The extension requires the storage permission in order to store options/accordion state and possibly a session on local storage.
Languages
Currently, the following languages are supported:
brief or mid-long calculations: in daily “browser” life, as a
mathematician, or as a programmer - there is support for all needs.
Formulas can be entered in the typical mathematician's or programmer's syntax - both is understood. There is also support for lengthy sessions (saving/restoring, exporting to clipboard, etc).
The original motivation was to experiment with a Pratt parser.
There is already a much richer expression syntax than in most languages
(implicit multiplication signs, no braces necessary for function calls),
and it would be simple to extend the syntax to a more full-blown “language”.
(In fact, earlier versions of calc-extension had a simpler syntax.
Readers interested in the parser implementation can check
data/js/parser.js).After installing calc-extension, it can be used as follows.
Click the calc-extension symbol
1+2.Then a page opens where you can enter a formula (see below) which will be
calculated when you press the solver button (
~>).(There is an option to use the enter key instead if you prefer.)
The result is then shown and you can enter the next formula.
You can also go back to an earlier entered formula and “recalculate” it
(e.g. after you modified some variables).
To remove a formula from your list, simply remove the main formula text
and press the solver button.
A simple formula is a usual mathematical expression which consists of numbers, the usual operators
+ - * / and braces ( ).As usual in mathematics (though not in most computer languages),
it is possible to omit the multiplication sign.
However:
Be aware that
x means the variable x and not a multiplication sign…!For multiplication use instead one of the symbols
* · × or simply omit it (a space can be used to separate adjacent tokens).The division symbol is
/ or :.Numbers have the usual floating-point format, e.g.
17 0.1 1.2e-3 or they can be octal or hexadecimal: For an octal number start with 0, for a hexadecimal number start with 0x.There are further operators which can be used in expressions:
- %remainder (“modulo”)
- **or- ↑exponentiation (binds from right to left)
- &bitwise AND
- |bitwise OR
- ^bitwise XOR
Note that functions bind stronger than all binary operators, i.e.
sin π/2 is the same as sin(π)/2 but differs from sin(π/2).
- sinthe sine, argument is in radians
- costhe cosine, argument is in radians
- tanthe tangent, argument is in radians
- asinthe arcsine, in radians
- acosthe arccosine, in radians
- atanthe arctangent, in radians
- sinhthe hyperbolic sine
- coshthe hyperbolic cosine
- tanhthe hyperbolic tangent
- asinhthe hyperbolic areasine
- acoshthe hyperbolic areacosine
- atanhthe hyperbolic areatangent
- log10the base 10 logarithm
- log2the base 2 logarithm
- logthe natural logarithm (base E)
- log1p- log(1+x)where- xis the argument
- expthe exponential function (base E)
- expm1- exp x - 1where- xis the argument
- sqrtthe square root, that is- sqrt x = x ** (1/2)
- cbrtthe cube root, that is- cbrt x = x ** (1/3)
- absthe absolute value
- signthe signum (1, 0, or -1)
- floorthe value rounded down to its nearest integer
- ceilthe value rounded up to its nearest integer
- truncthe value rounded to the integer of smaller absolute value
- roundthe value rounded to its nearest integer
- froundthe value rounded to the nearest 32 bit float
- clz32the number of leading zero bits in a 32 bit representation
Furthermore, there are constants available:
- EEuler's number exp 1
- PIor- πthe circle number acos -1
- SQRT2sqrt 2
- SQRT1_2sqrt 1/2
- LN2log 2
- LN10log 10
- LOG2Elog2 E
- LOG10Elog10 E
- EPSILONor- εthe distance of 1 to the smallest larger floating point number
Finally, it is possible to define variables with e.g.
a=... and to use them.Variable names must only consist of English characters, numbers, or
_.The whole syntax and operator precedence is inspired by javascript.
However, the following things are new.
There is a special variable name
# which always refers to the result ofthe last (succesful) calculation.
There are also special sequences which can occur anywhere in an expression
and which cause options to switch (you can also switch them by the mouse).
To modify options more permanently (also for future sessions even across
browser restarts), you have to set them in the preferences window.
- 'width:height'default is 60:1
- "base"switch output to base (2-36)
- !new input fields are textareas (multiple lines)
- ?new input fields are for single lines
The actual calculation of the functions and number conversion occurs
by javascript calls. Therefore, mathematical properties like available
precision, error messages, number limitations, and possible inaccuracies
(and possibly even bugs) are inherited from the javascript interpreter.
Example session
- 1 + 2(1+1) + (2-1)(3-2)
- ~> 6
- 1·1 + 1×1 + 1 1 + 1*1
- ~> 4
- 2↑2↑3 - 2**8 + 4/3 - 1:3
- -> 1
- 1 - cos π/2 + cos(PI/2)
- ~> 1.5
- a = 3(# + 1)
- ~> 7.5
- # + 4a
- ~> 37.5
- 0xF | 0100 "16"
- ~> 4f (in base 16)
Permissions
The extension requires the storage permission in order to store options/accordion state and possibly a session on local storage.
Languages
Currently, the following languages are supported:
- en (default language)
- de
Được xếp hạng 5 (bởi 1 người dùng)
Thêm thông tin
- Liên kết tiện ích
- Phiên bản
- 5.4resigned1
- Kích cỡ
- 49,51 KB
- Cập nhật gần nhất
- 2 năm trước (25 Thg 04 2024)
- Thể loại có liên quan
- Giấy phép
- Chỉ Giấy phép Công cộng GNU v2.0
- Lịch sử các phiên bản
- Thêm vào bộ sưu tập