5.4. Calc Package¶
Available since version 2.0
The Calc package allows to quickly evaluate a mathematical expression directly from Keypirinha and eventually copy its result to the clipboard. It also offers base conversion of integers (hexadecimal, binary, octal) and currency formatting.
5.4.1. Catalog Items¶
This package populates the Catalog with the following items:
The
=
item, which argument is expected to be the mathematical expression to evaluate.
Tip
You do not need to use the
=
item to start typing your mathematical expression. This plugin allows to you to enter it directly and it will be evaluated as long as its syntax is valid.It is also possible to prefix your expression with the
=
keyword to indicate the plugin you wish the trailing part to be evaluated in case thealways_evaluate
option is disabled.
5.4.2. Configuration¶
This package is configurable, more details about every setting can be found in its configuration file.
See also
The Configuration chapter
5.4.3. Mathematical Expression¶
To some extent, Calc tries to support any mathematical expression supported by the Python language. Some functions also have been added.
5.4.3.1. Quick Examples¶
1 + 2
-1 + 2
(prefix sign)sin(2)
(function)sin(2.345) + 1.09
(floating point)pi
(some constants are pre-defined)(3+4)*2
(parentheses are supported)3^3
or3**3
(power of)2k
(number suffix; see section below)0xa
(hexadecimal numbers will be converted to decimal)0b100
(binary numbers will be converted to decimal)0o3
(octal numbers will be converted to decimal)0b100 * 0x2
(hexadecimal and binary numbers can be used in operations as well)Bitwise operators:
1 << 2
(left shift)10 >> 1
(right shift)1 & 2
(AND)1 | 2
(OR)1 ~ 2
(XOR)
5.4.3.2. Predefined Constants¶
Name |
Value / Meaning |
---|---|
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
The result of the last valid operation |
5.4.3.3. Number Suffixes¶
To ease input, it is possible to specify a multiple of a number by its
name.
Example: 1Ki
is equal to 1024
.
Warning
Suffixes are case-sensitive which means Ki
is not equivalent to
ki
.
This package supports the following suffixes:
Metric System:
Suffix |
Name |
Expands to |
---|---|---|
|
yocto |
|
|
zepto |
|
|
atto |
|
|
femto |
|
|
pico |
|
|
nano |
|
|
micro |
|
|
milli |
|
|
centi |
|
|
deci |
|
|
deca |
|
|
hecto |
|
|
Kilo |
|
|
Mega |
|
|
Giga |
|
|
Tera |
|
|
Peta |
|
|
Exa |
|
|
Zetta |
|
|
Yotta |
|
Orders of Magnitude of Data:
Suffix |
Name |
Expands to |
---|---|---|
|
Kibi |
|
|
Mebi |
|
|
Gibi |
|
|
Tebi |
|
|
Pebi |
|
|
Exbi |
|
|
Zebi |
|
|
Yobi |
|
5.4.3.4. Core Functions¶
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
5.4.3.5. Math Functions¶
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
|
See Python’s |
5.4.3.6. Random Functions¶
|
Usage: |
|
See Python’s |
|
See Python’s |
|
See Python’s |