Skip to content

Unary Operators

Arda Özcan edited this page Sep 13, 2020 · 1 revision

Table of Contents

Unary Operators

Positive

+ operator does nothing to a numerical type.

Supported and resulting types:

  • +int = int
  • +float = float
  • +double = double

Examples:

int new = +3 # 'new' is 3
float new = +3.0f # 'new' is 3.0f
double new = +3.0 # 'new' is 3.0

Negative

- operator negates a numerical type.

Supported and resulting types:

  • -int = int
  • -float = float
  • -double = double

Examples:

int new = -3 # 'new' is -3
float new = -3.0f # 'new' is -3.0f
double new = -3.0 # 'new' is -3.0

Clone this wiki locally