Operator

-(_:)

Returns the additive inverse of the specified value.

Declaration

Return Value

The additive inverse of the argument.

Discussion

The negation operator (prefix -) returns the additive inverse of its argument.

let x = 21
let y = -x
// y == -21

The resulting value must be representable in the same type as the argument. In particular, negating a signed, fixed-width integer type’s minimum results in a value that cannot be represented.

let z = -Int8.min
// Overflow error

See Also

Performing Mathmatical Operations

func negate()

Replaces this value with its additive inverse.

static func *= (inout DispatchQueue.SchedulerTimeType.Stride, DispatchQueue.SchedulerTimeType.Stride)

Multiplies the values of the two arguments, and assigns the result to the first argument.

static func += (inout DispatchQueue.SchedulerTimeType.Stride, DispatchQueue.SchedulerTimeType.Stride)

Adds the values of the two arguments, and assigns the result to the first argument.

static func - (DispatchQueue.SchedulerTimeType.Stride, DispatchQueue.SchedulerTimeType.Stride) -> DispatchQueue.SchedulerTimeType.Stride

Returns the result of subtracting the value of the second argument from the value of the first.

static func -= (inout DispatchQueue.SchedulerTimeType.Stride, DispatchQueue.SchedulerTimeType.Stride)

Subtracts the value of the second argument from the value of the first, and assigns the result to the first argument.