Alfred Workflow for calculating SI value inverse

Andrzej Wojciechowski

Recently I have finally decided to try Alfred – a well known productivity tool for macOS. Especially with additional Powerpack it enables a ton of automation and customization. A lot of Alfred Workflows can be found on the internet, but I couldn’t find one for calculating an inverse of numbers containing SI prefix. So I have decided to create it by myself.

Motivation

I sometimes need to quickly convert some frequency value to the equivalent period value – e.g. to define a constant clock frequency in a testbench. For example 50 MHz frequency is the equivalent of 20 ns period. The formula is trivially simple: frequency = 1 / period. It’s essentially an inverse of the input. The problem lies in SI unit prefixes: most often ‘kilo’, ‘mega’, ‘nano’, ‘micro’ etc. If you try to calculate the period of 50 MHz and type in the calculator: 1/50e6, you will the result of 0.00000002. Good luck with counting all those zeros quickly. Ideally the result would contain an SI prefix (like ‘n’ or ‘nano’ in this case). And preferably also accept the input value with a prefix.

Because I couldn’t find any Alfred Workflow performing inverse operation with prefixes, I created it by myself. It’s available in my GitHub repository. It’s not limited to frequency <-> period conversions, but can be used for any units – e.g. converting electrical resistance (in Ω) to electrical conductance (in S) and vice versa.

How to calculate an inverse using the Alfred Workflow

Once the Workflow is installed, simply enable Alfred using predefined hotkey and type in ‘inv’ followed by a value to invert. That’s all! You can use the SI prefix or the SI prefix with a unit. Below you can find the example of how the result looks like.