Operator: %

operator % { associativity left precedence }

Declarations

func %(_: Int, rhs: Int)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: Int, rhs: Int) -> Int
func %(_: Int8, rhs: Int8)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: Int8, rhs: Int8) -> Int8
func %(_: Int16, rhs: Int16)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: Int16, rhs: Int16) -> Int16
func %(_: Int32, rhs: Int32)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: Int32, rhs: Int32) -> Int32
func %(_: Int64, rhs: Int64)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: Int64, rhs: Int64) -> Int64
func %(_: UInt, rhs: UInt)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: UInt, rhs: UInt) -> UInt
func %(_: UInt8, rhs: UInt8)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: UInt8, rhs: UInt8) -> UInt8
func %(_: UInt16, rhs: UInt16)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: UInt16, rhs: UInt16) -> UInt16
func %(_: UInt32, rhs: UInt32)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: UInt32, rhs: UInt32) -> UInt32
func %(_: UInt64, rhs: UInt64)

Returns the remainder of dividing the first value by the second.

The result of the modulo operator (%) has the same sign as lhs and is less than rhs.magnitude.

let x = 22 % 5
// x == 2
let y = 22 % -5
// y == 2
let z = -22 % -5
// z == -2

For any two integers a and b, their quotient q, and their remainder r, a == b * q + r.

Parameters: lhs: The value to divide. rhs: The value to divide lhs by. rhs must not be zero.

Declaration

func %(lhs: UInt64, rhs: UInt64) -> UInt64