# Calculator

LaunchBar’s built-in Calculator allows you to quickly perform numeric calculations. Just type Command-Space, type your calculation and press Return. LaunchBar’s built-in Calculator

## Opening the Calculator

To open the Calculator, do one of the following:

• Press the Calculator keyboard shortcut, which can be configured in the Calculator pane LaunchBar preferences.
• Choose Select > Calculator (or press Command-=).
• Type an abbreviation to select the Calculator item (e.g. CALC or '='), then press Space.
• Type your calculation right away, e.g. just type 13 + 5 and press Return.
• Paste a calculation or just a series of numbers onto LaunchBar (Command-V).
Entering leading digits (either by typing them or via 'paste') automatically switches to Calculator. This behavior can be turned off in LaunchBar preferences > General > Switch to Calculator when typing digits.

## Examples

Operation Example
Basic arithmetical operations 44 - 16 * (12.3 + 4.8 / 3)
Trigonometric operations sin(pi / 2)
Inverse trigonometric operations atan(1)
Square Root sqrt(2)
Raise to power pow(27 | 1/3)
Raise to integral power 2^8
Exponential function ex exp(1)
Logarithm (base 10) log(1000)
Natural logarithm ln(2.71828182846)
Binary logarithm ld(1024)
Greatest common divisor gcd(527 | 697)
Least common multiple lcm(91 | 143)

## Multiple arguments

If a function has more than one argument (such as pow or gcd), the arguments have to be separated with a vertical line character | to prevent ambiguities with decimal and thousand separators.

To enter this separator more conveniently, you can also press either Tab or \.

## Smart Calculator Input

To speed up typing your expressions (especially on notebook keyboards), LaunchBar provides some smart conversions during input or prior to calculating the result:

• The plus sign can be omitted between consecutive numbers. For example, 13 9 8.3 will be converted to 13+9+8.3.
• In some cases the multiplication operator can be omitted as well. For example, you can type 17(3+5) or 2pi to get 17*(3+5) or 2*pi.
• Square brackets can be entered as an alternative to parentheses.
• A lowercase x can be used for multiplications as an alternative to '*'
• The Equals sign '=' can be typed to enter '+'.
• The key left from the "1" key can be used to enter a decimal separator.

## Smart Brackets

Calculator automatically inserts closing brackets if appropriate. When you type an opening bracket, the corresponding closing bracket will inserted automatically.

To put some part of an already entered expression in brackets, select that part and type a bracket. Entering an opening bracket will put the insertion point before the bracketed expression, entering a closing bracket will put it behind.

Smart Brackets can be turned off in the General pane of LaunchBar preferences.

## Function Shortcuts

Uppercase letters can be used to enter function names more quickly. For example, type S45 to get sin(45), or type Q2 to get sqrt(2).

Input Result
S sin(x)
C cos(x)
T tan(x)
AS asin(x)
AC acos(x)
AT atan(x)
Q sqrt(x)
L ln(x)
D ld(x)
G log(x)
E exp(x)
P pow(x|y)
X pow(10|x)
R 1/x
Shift-2
Shift-3
You can select an expression prior to typing the shortcut to use the expression as the function’s argument. For example, when you’ve selected the number 43, typing S results in sin(45).

## Automatic Decimal Separator Detection

Calculator automatically detects the used notation for decimal- and thousand-separators (period vs. comma). So you may enter either 12.3 + 1,550 or 12,3 + 1.550 and you’ll get the expected results in both cases.

In ambiguous cases (e.g. 12.000 + 3,123) LaunchBar considers the number format as specified in System Preferences > Language & Text > Formats.

## Calculating Sums

To calculate the sum of a series of numbers, you can omit the plus signs. It’s sufficient to separate the numbers with a space character, or if you enter them via Copy & Paste they just have to be in separate lines (so you can paste e.g. a column of numbers).

## Instant Calculate

With Instant Calculate you can quickly perform calculations via Instant Send. If the sent text appears to be a valid calculator expression, the results are displayed automatically.

For example, if you are working on a document that contains a series of numbers, you can select these numbers, send them to LaunchBar via Instant Send, and LaunchBar will instantly show the sum of these numbers.

## Non-contiguous Selections

Many OS X applications support non-contiguous text selections, allowing you to select multiple, individual pieces of text. You first select one piece of text, then hold down the Command key and select some other text elsewhere in the document. For example, the following TextEdit selection was created by double clicking the first, third and fourth number while holding the Command key down: Now copy and paste this text selection from TextEdit to LaunchBar, and you will get the following result: Or if you are using Instant Calculate as described above, you’ll get the sum of these numbers with just a single keystroke: ## Subsequent Calculations

When the result of a calculation is displayed in large type, you can press Space to modify the current expression, or press Tab, +, -, *, / or A to perform subsequent calculations based on the current result.

The letter “a” can be used as a placeholder for the most recent result, which is especially useful if you want to use this result in different places of your new expression. For example, if your last calculation delivered 7.24 as the result you can enter:

(a + 3) / a

which will then evaluate to:

(7.24 + 3) / 7.24

## Invoking Calculator from external applications

Calculations can be sent from external applications to LaunchBar via AppleScript or URL commands. The result of the expression is then displayed in large type.

### AppleScript

Calculation requests can be sent to LaunchBar via AppleScript using the perform action command. For example:

tell application "LaunchBar"
perform action "Calculator" with string "(1+sqrt(5))/2"
end tell

### URL commands

Calculation requests can also be sent to LaunchBar using the x-launchbar:calculate URL command. You can optionally specify input and output formats to customize the display of the result. Special characters must be properly URL encoded using UTF-8 percent escapes.

### Search Templates

The x-launchbar:calculate URL command can also be used to compute the result of predefined formulas via Search Templates.

Convert Fahrenheit to Celsius
x-launchbar:calculate?argument=*&expression=(@-32)/1.8&title=@%c2%b0F%20=&result=@%c2%b0C
Convert Celsius to Fahrenheit
x-launchbar:calculate?argument=*&expression=@*1.8+32&title=@%c2%b0C%20=&result=@%c2%b0F