Programmer's Calculator in Python for Visual Studio Code. This is an inline calculator to use inside any document view in Visual Studio Code. Use inside existing views (e.g. source files) for quick inline calculations or dedicate a blank/unsaved view to use as an embedded standalone calculator.
Simply select an expression (or multiple expressions using multiple selections) and execute the calculator by pressing the keyboard shortcut and the selection(s) will be replaced by the result of the calculation. Alternatively, if there are no selections, the line of the cursor will be parsed and the result inserted on the line after it (also works with multiple cursors). This is useful when using it as a normal calculator to incrementally perform a sequence of calculations using the result of the previous calculation as input for the following calculation leaving each step in the series of calculations visible.
Procapy supports any valid Python, and will reduce the result of any expression to a number (or an error string if something did not parse correctly).
The default keyboard shortcuts are:
In addition to the Python standard functions, math and cmath modules (the latter imported into the cmath namespace), Procapy adds the following functions that are useful in programming:
These are similar to the built-in function int(x) which will truncate to an integer of unlimited width.
In addition, the variable n is assigned a value matching the index of each selection. This can be used in mathematical expressions to form different results for each selection.
Difference between two hex numbers:
Same but truncated to 32bit unsigned range which reveals the two's complement encoding of the negative number:
Division and addition:
Same but adding truncation to 8bit unsigned of intermediate results:
Interpretation of a positive hex number as unsigned integer:
Same but showing truncatated to 32bit signed integer, revealing the value when interpreted as a two's complement encoding:
Comparison operators return True/False in decimal mode and 0/1 in hex/binary/octal:
Same but with truncation of intermediate result to 32bit unsigned integer:
Mixed radix calculations:
Bitwise operators (OR, NOT, AND, XOR):
Boolean operators and (in)equality:
Icon designed by Freepik from Flaticon
Initial release of Procapy