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?
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