# unaryPlus

Learn how to use the unaryPlus (+) operator in Notion formulas.
The unaryPlus (`+`) operator is used to convert Booleans and numeric strings to numbers.
1
+string
2
+Boolean
3
4
unaryPlus(string)
5
unaryPlus(Boolean)
Unlike toNumber, it cannot convert dates to numbers. Otherwise, it is functionally equivalent, and it can be written with the `+` operator for quick use.
You can also use the function version, `unaryPlus()`.
Good to know: A unary operator only has a single operand, while a binary operator has two. unaryPlus and unaryMinus are, as their names imply, unary operators. Examples of binary operators include add, divide, pow, etc.

## Example Formulas

1
+"42" // Output: 42
2
3
+true // Output: 1
4
5
+false // Output: 0
6
7
unaryPlus("42") // Output: 42
`unaryPlus()` can be combined with other operators, including unaryMinus and even add, which uses the same `+` character.
1
20 + + "30" // Output: 50
2
3
-+"30" // Output: -30
4
5
20 + - + "30" // Output? -10 [Notion will rewrite this to 20 + -(+"30")]
Using `unaryPlus()` on a string value that contains any non-numeric characters will result in null output. However, that "null" output is still considered to be a number in terms of its data type.
This can cause formulas that contain additional functions or output to throw a Type Mismatch error.
Oddly, `+""` returns `0` rather than `null`. This is contrary to the equivalent toNumber formula: `toNumber("")` returns `null`.
1
+"Monkey" // Output: null (but still Number type)
2
3
+"42 Monkeys" // Output: null (but still Number type)
4
5
+"" // Output: 0
6
7
+"Monkeys" + 22 // Output: 22
8
9
+"Monkeys" + " and rabbits loop the loop" // Output: Type Mismatch Error

## Example Database: Daily Habit Score

The example database below tracks daily habits with a checkbox property for each habit. The Score property converts each checkbox’s Boolean value into a number, and then adds up a total score for the day.

### "Score" Property Formula

1
+prop("Deck Swabbed") + +prop("Teeth Brushed") + +prop("Lime Eaten")

## Example Database: Numeric Phone Numbers

Notion's Phone Number property type outputs a string (see it listed in the API Reference for more detail).
The example database below uses unaryPlus and the replaceAll function to turn phone numbers into true numbers, even if they have additional formatting.

### “Number” Property Formula

1
+replaceAll(prop("Phone"), "[() -]", "")
unaryPlus can’t operate on a string that contains non-numeric characters such as `(` or `-`. So Number first uses the replaceAll function to remove them. It does this by passing a regular expression in its matching argument - `"[() -]"` - where the special bracket `[]` characters equate to:
“Match any character listed here.”
This includes the `space`.
Next, `replaceAll()`'s replacement argument replaces all matched characters with an empty string - `""` - in effect removing them. The result is a phone number converted to a purely numeric string - e.g. `(482) 491-5813` is converted to `4824915813`.
Finally, the `+` operator converts this numeric string into a true number.