Updated extension: Calculate

The Calculate extension is now updated to support macOS Monterey. It also gained some new abilities.

Full readme:

Calculate

Evaluate the text as mathematical expression.

Calculate-demo

The result is displated as the action’s button title. Clicking the action button will paste or copy the result. (Holding Shift (⇧) will always copy.)

Examples with simple arithmetic:

  • 1 + 12.

  • 15/27.5

  • (50 + 1) * 2 - 597.

It can also support quite complex expressions, as supported by mathjs:

  • 155 miles * 18% in km44.9006976 km

  • sqrt(4)2

  • sin(pi/2)1

  • 4(2 + 3i)8 + 12i

  • a = 2; b = 3; 2a + b7

If the input text ends with an = character, the result will be appended to the input instead of replacing it. For example:

  • 100/4=100/4=25

About

This is an extension for PopClip.

Author

Nick Moore

Requirements

Requires PopClip 2021.11.

Notes

The extension is implemented using mathjs. The evaluation is performed using the evaluate() function of the library.

Changelog

v2 - 8 Nov 2021

  • Rewritten in JavaScript using mathjs library.

  • Displays result as title of button.

v1 - 8 Apr 2013

  • Initial release (PHP).
2 Likes

Fabulous! I use this extension all the time, and the new features look great.
Thanks! :grinning:

1 Like

Hi, thanks again… But one thing is missing (I think it was ok in the previous version !) : is it possible that Calculate use the , and not only the . for decimal values ??? In French we use the , as separator for the decimal values (defined in the prefs of macOS)
Thank you in advance
Ange

1 Like

Thanks for mentioning this @Ange. I’m working on this but it is proving a little trickier than I thought. I’ll let you know when it is ready.

1 Like

Thanks, perhaps through a pref for the calculate module with either a list of choices for the separator ? or to indicate which system we want to use (as the MacOS finder proposes) ?

I’ll see !

Regards,
Ange

I was planning to have it be the same as the macOS system preference. Would that be suitable?

It is not exactly as you show in your snapshot. Snapshot of my macOS prefs (main difference relative to your snapshot : position of the money symbol, words in FR without capitals ;-),

Ah yes, that’s because I have mine set to English and yours is set to Français. But I just mean, that the decimal separator (, or .) will be taken from the macOS setting.

so ok, it’s exactly that ! . or , !

1 Like