How to use Spotlight as more than a simple calculator

SpotlightIconXIf you ever need to run a quick calculation or two when working on your Mac, then you can do so using Apple’s Spotlight search; however, while you might find yourself using this for basic addition and multiplication, Spotlight’s calculations support far more, and if used properly can be just as if not more valuable than Apple’s included Calculator utility.

If you are unfamiliar with using Spotlight as a calculator, then you can access it quickly by pressing Command-Space to invoke Spotlight, followed by simply typing your equation, such as “1+4” which will show you a top hit of “5” next to an icon representing the calculator. At this point, you can press Enter to directly open the calculator (though it will be at 0 and not be passed the result of this calculation), or you can press Command-C on the highlighted result, to copy it to the clipboard.

Calculator in OS X Yosemite

All of these calculator functions can be performed directly in the Spotlight search field, instead of needing to open the Calculator program.

Now you might be inclined to just use Spotlight for a quick addition or multiplication, but you can also use it for anything from trigonometric functions (sin, cos, tan, etc.), to calculating roots, rounding in various ways, among other useful features. To help with this, here is the list of supported functions you can use in Spotlight:

Basic Operators

The basic operators in Spotlight’s calculator are the classic +, -, *, / symbols for addition, subtraction, multiplication, and division, but in addition you have the following ones available for more complex math:

! — The factorial, for multiplying every integer between 1 and the specified number
% — The modulus symbol, used similarly to division, but will issue you the remainder in division, rather than the full ratio.
^ — The exponent, used between two numbers will raise one to the power of the other.
() — Parentheses, used for containing values and isolating orders of operation.

Built-in constants

Spotlight has a couple of standard numerical constants defined, namely pi and e:

pi — the classic 3.1415…, or the complete distance of half of the unit circle
e — euler’s number, used for natural logarithms and exponents

Trigonometric Functions

The trigonometric functions, along with their arc and hyperbolic equivalents, are also available:

sin() — Standard sine
cos() — Standard cosine
tan() — Standard tangent

asin() — Standard arcsine
acos() — Standard arccosine
atan() — Standard arctangent

sinh() — Hyperbolic sine
cosh() — Hyperbolic cosine
tanh() — Hyperbolic tangent

asinh() — Hyperbolic arcsine
acosh() — Hyperbolic cosine
atanh() — Hyperbolic tangent

Note that the trigonometric functions are performed in classic Radian mode, so you must first convert degrees measurements to radians (i.e., multiplying by pi/180).

Exponents and Logarithms

You can always use the exponent operator “^” to get exponents; however, you can also use defined options:

exp() — This is the natural exponent, or equivalent of raising to the power of “e” (e^num)
E — This allows you to write “*10^number”, such as the following (10E4 for 10*10^4)
log() — This takes the base10 logarithm of the given number
ln() — This takes the natural logarithm of the number

For logarithms of other bases besides e and 10, you can use the basic math conversion of dividing the base10 logarithm by the base10 log of the new base, for instance to get the log2 of a number “x”, you can do the following in Spotlight: log(x)/log(2)

Spotlight as a calculator in OS X

You can type in long and sometimes complex-looking equations directly into Spotlight to get your results. Here we are basically computing e^-0.5.

Roots

The square and cube roots are available as built-in functions; however, you can also use fractional exponents:

sqrt() — The standard square root of the given number
cbrt() — The cube root of the given number

For other roots besides the square and cube root, you can use exponents in the form X^Y, where you can take x^(1/4) to get the fourth root, or x^(1/5) to get the fifth root, etc.

Rounding

Finally, you can use the following functions to round, truncate, and get the absolute value of numbers:

ceil() — Gives you the closest integer by rounding up
floor() — Gives you the closest integer by rounding down
rint() — Gives you the closest integer by standard rounding
fabs() — Gives you the absolute value of a number.

M+, M-, MR options in Spotlight

While the calculator has a M+, M- and MR options for storing values, you can do the same with Spotlight by pressing Command-C to copy the results of a calculation to the clipboard. From here, you can create new equations by pasting the results back into equations you are creating in Spotlight, and then again copying the results to the clipboard to save them.

6 thoughts on “How to use Spotlight as more than a simple calculator

  1. Strod

    Ooooooh! Topher finally wrote a full article on one of my favorite features of OS X! I use it all the time, several times per hour, sometimes even when I have Matlab open (because I don’t want the calculation to disrupt my line of thought in the Matlab session and opening a second session would be too slow).

    I didn’t know some of the functions, like cbrt, rint, or fabs. Thank you SO MUCH for pointing them out.

    A few comments:

    – You do NOT need to convert from degrees to radians, just use the degree versions of the trigonometric functions: sind, cosd, tand, and their inverses asind, acosd, atand.

    – The % sign works in two different ways, depending of context. So for example 43%5 = 3, because it is interpreted as the modulo operator, as Topher explained. But 43%*5 = 2.15, because that is the 43 percent of 5.

    – Similarly, the lowercase letter “e” may be Euler’s constant, but if placed between two numbers it means “*10^”, just as uppercase “E” does.

    – Juxtaposition of numbers, functions, or expressions in parenthesis are interpreted as multiplication: 3 sind(45) sqrt(2) (2+1) = 8.9999999979 (Note that it’s really 9, but there are small rounding errors in the sine and the square root. Note also that all the spaces are optional in this case.)

    – A consequence of the two previous comments is that spaces may change the result: 10e10 = 100000000000 (a one with 11 zeros), but 10e 10 = 10 e10 = 10 e 10 = 100*e = 271.82818285

    – The trick to get logarithms in other bases works with any base… I mean, you can use ln instead of log and save a couple of keystrokes: log(23)/log(2) =ln(23)/ln(2) = log2 of 23.

  2. forkboy1965

    I don’t know anything about all the more advanced capabilities, but I make use of the Spotlight for basic calculations all the time. I no longer recall when or where I first learned about this, but it’s incredibly handy for a quick calculation.

  3. Steffen

    I tried the modulo operator, but it seems it doesn’t work in 10.10.2.
    It’s always interpreted as percentage operator.

Comments are closed.