Name | Type | iOS | tvOS | watchOS | macOS |
---|---|---|---|---|---|
abs |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
asLocaleCurrency |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
degreesToRadians |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
digits |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
digitsCount |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
isEven |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
isOdd |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
radiansToDegrees |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
romanNumeral |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
timeString |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
kFormatted |
Read-Only Property | 8+ | 9+ | 3+ | 10.10+ |
gcd(of n: Int) |
Method | 8+ | 9+ | 3+ | 10.10+ |
lcm(of n: Int) |
Method | 8+ | 9+ | 3+ | 10.10+ |
randomBetween(min: Int, max: Int) |
Static Method | 8+ | 9+ | 3+ | 10.10+ |
** |
Infix Operator | 8+ | 9+ | 3+ | 10.10+ |
√ |
Prefix Operator | 8+ | 9+ | 3+ | 10.10+ |
± |
Infix Operator | 8+ | 9+ | 3+ | 10.10+ |
± |
Prefix Operator | 8+ | 9+ | 3+ | 10.10+ |
--
Absolute value of integer.
- type: Read-Only Property.
- return type: Int
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
1.abs -> 1
(-1).abs -> 1
--
String with number and current locale currency.
- type: Read-Only Property.
- return type: String
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
1.asLocaleCurrency -> "$1.00"
--
Radian value of degree input.
- type: Read-Only Property.
- return type: Double
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
180.degreesToRadians -> 3.141592653589793
--
Array of digits of integer value.
- type: Read-Only Property.
- return type: [Int]
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
123.digits -> [1, 2, 3]
--
Number of digits of integer value.
- type: Read-Only Property.
- return type: Int
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
123.digitsCount = 3
--
Check if integer is even.
- type: Read-Only Property.
- return type: Bool
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
2.isEven -> true
1.isEven -> false
--
Check if integer is odd.
- type: Read-Only Property.
- return type: Bool
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
1.isOdd -> true
2.isOdd -> false
--
Degree value of radian input
- type: Read-Only Property.
- return type: Double
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
1.radiansToDegrees -> 57.29577951308232
--
Roman numeral string from integer (if applicable).
- type: Read-Only Property.
- return type: String?
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
13.romanNumeral -> "XIII"
(-6).romanNumeral -> nil
--
String of format (XXh XXm) from seconds Int.
- type: Read-Only Property.
- return type: String
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
13.timeString -> "13 sec"
516.timeString -> "8 min"
4243.timeString -> "1 h 10 m"
--
String formatted for values over ±1000 (example: 1k, -2k, 100k, 1kk, -5kk..)
- type: Read-Only Property.
- return type: String
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
13.kFormatted -> "0K"
1209.kFormatted -> "1k"
(-4000).kFormatted -> "-4k"
--
Greatest common divisor of integer value and n.
- type: Method.
- return type: Int
- parameters:
- n: integer value to find gcd with.
- returns: greatest common divisor of self and n.
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
124.gcd(of: 12) -> 4
--
Least common multiple of integer and n.
- type: Method.
- return type: Int
- parameters:
- n: integer value to find lcm with.
- returns: least common multiple of self and n.
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
4.lcm(of: 3) -> 12
--
Random integer between two integer values.
- type: Static Method.
- return type: type
- parameters:
- min: minimum number to start random from.
- max: maximum number random number end before.
- returns: random integer between two integer values.
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
Int.randomBetween(min: 5, max: 25) -> 20
--
Value of exponentiation.
- type: Infix Operator.
- return type: Double
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
2 ** 3 -> 8
5 ** 2 -> 25
--
Square root of integer.
- type: Prefix Operator.
- return type: Double
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
√ 25 -> 5.0
--
Tuple of plus-minus operation.
- type: Infix Operator.
- return type: Double
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
2 ± 2 -> (0, 4)
--
Tuple of plus-minus operation.
- type: Infix Operator.
- return type: Double
- availability:
iOS 8+
tvOS 9+
watchOS 3+
macOS 10.10+
.
Example
± 2 -> (-2, 2)