Instance Method

negate()

Replaces this value with its additive inverse.

Declaration

mutating func negate()

Discussion

The following example uses the negate() method to negate the value of an integer x:

var x = 21
x.negate()
// x == -21

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

var y = Int8.min
y.negate()
// Overflow error

See Also

Performing Mathmatical Operations

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.