This is brilliant! It will save me trips to Spotlight, my calculator of choice when the HP is too far out of reach.

I made one change to your macro which allows more complex math(s) to occur at the expense of useless trailing zeros showing up when doing non-integer math(s):

(That's a pipe "|" between the double quote and the "bc", and that's a lower-case "L" at the end of the expression.)

Change the "scale=" expression to the number of decimal places you wish when the result is not an integer. I can't seem to find a way to make bc act any more sensibly, but it does work. The "-l" option is entirely optional, but it does get you a few trig and other functions. See the manpage for bc here:

...and then I realized just how ridiculous I was being to replace the Calculate filter, with its extensive list of functions, with bc, and its meager set of functions. I did, however, learn things along the way, so all is not lost.

But the reason I did it in the first place is because I tried the expression "sqrt(2)" and got... nothin'. (I'm an EE, so sqrt(2) is somewhat important.) So I thought, Heck, if Calculate can't do a square root, it must be rather basic. Better write a replacement. (What little I knew!)

So that leaves me with the question, Did I miss "sqrt" somewhere in the list, or is it truly not one of the Calculate functions?

I just checked and it is documented in the Calculations user manual section, so if you want to see if there is anything else there of interest, that mighty be worth taking a look at.

I have added the following Action to Peter's macro just before the last Action of "Insert Text":

Limit the Number of Decimals In Output

This rounds to two decimal places, IF more than two are the result of the calculation.
IF Calc is already less than two decimals, then it is output as is.

Of course, you could change to any number of places, just by replacing the "100" in the calculation with another power of 10.

Is it possible to use the comma instead of the full stop as the decimal delimiter?

And: Is it possible to always have two decimals (as is default in currency calculations)?

On a side note: I'm not a programmer, so I was a little puzzled by the notation with the three equal signs. Besides that, I wanted to have the originating calculation inserted too:

It should format the number in the Result variable according to your localized currency notation. A bit more information on the CalculateFormat token (which is new to KM 8 and thus not part of this original thread) here: https://wiki.keyboardmaestro.com/token/CalculateFormat

That's what I expected (that the decimal point is used internally for calculations). Well, I can always filter the variable to replace the point with a comma before it is typed.

This is what the CalculateFormat token is for. Assuming you have a variable named Number with a value it in, you can use the text token:

%CalculateFormat%Number%Decimal%

And it will format it using localised conventions.

Same for:

%CalculateFormat%Number%#,##0.00%

Even though the format there shows "," as a separator and "." as a decimal, they will be replaced with the localised equivalents (maybe space and , for example).