The Shortcuts app has three actions that are most commonly used to perform math calculations. The first is the Calculate action, which is primarily used to perform basic math operations. However, clicking on the plus character and selecting the ellipsis character yields additional options.
The shortcut included below is a simple calculator that demonstrates a use of the Calculate Expression action. This shortcut supports text replacements to facilitate the entry of math operators and shows the prior calculation. macOS Golden Gate 27 is required.
The following are a few additional math operators that can be used with these shortcuts, although I suspect anyone who needs these will be using a proper scientific calculator.
exponent ^ or **
square root √
cube root ∛
Factorial !
modulus %
Pi π
The shortcut included below is another example that uses the Calculate Expression action. It performs various conversions including distance, volume, mass, time, and temperature. This shortcut requires macOS Golden Gate and the open source swiftDialog utility.
This shortcut is similar to the above, differing in the following respects:
It should work with any version of macOS that supports the Shortcuts app, although it has only been tested on macOS Golden Gate 27.2.
It does not require the swiftDialog app.
The text replacement codes are intended for use with frequently-used conversions. Thus, for example, acceptable user input includes 100 kilograms to pounds and 100 kp (see the Dictionary action in the screenshot).
There are two actions whose primary purpose is to convert a value from one unit of measurement to another. They are described as:
Measurement. Passes the specified measurement (including number and unit) to the next action.
Convert Measurement. Converts the measurements passed into the action to the specified unit.
It should be noted that the Measurement action creates a measurement object consisting of a numeric value and a unit of measurement, and the Convert Measurement action requires a measurement object as input. The following is a simple example of their use.
In limited testing, many but not all of the units of measurement were supported by the Calculate Expression action and will work with my shortcuts included above.
I was curious what a typical use-scenario might be for the Measurement and Convert Measurement actions. An obvious use is to convert a single value from one specific unit of measurement to another.
When multiple conversion options are needed, the Calculate Expression action should probably be used. If that’s not feasible, the following aproach might be considered. It requires macOS Golden Gate.