Unary

A unary expression returns different results depending on which of the unary operators is used.

Expression

Character representation

Returns

Unary

-

The arithmetic negation of the operand, or null if the operand is null.

 

+

The arithmetic value of the operand (unchanged), or null if its operand is null.

 

not

The logical negation of the operand.

Note: The arithmetic negation of a null operand yields the result null, whereas the logical negation of a null operand yields the Boolean result true. This is justified by the common sense statement: If null means nothing, then “not nothing” should be something.

These are examples of using the unary expression:

Expression

Returns

-(17)

-17

-(-17)

17

+(17)

17

+(-17)

-17

not("true")

1 (true)

not(1)

0 (false)

// Ethnio survey code removed